Skip to content

🗺️ Middleware #12695

Closed
Closed

Description

@ryanflorence

Activity

  1. knownasilya commented on Mar 12, 2024

    @knownasilya
    Contributor

    What's the status on this? Specifically asking for ReactRouter because the root loader doesn't run first there and it seems like everyone using ReactRouter (personally as a stepping stone to Remix) is floundering (see #9327) on how to do authentication.

  2. nilansaha commented on Sep 27, 2024

    @nilansaha

    Is there any update on this? Authentication is probably the biggest use case.

  3. chasoft commented on Oct 4, 2024

    @chasoft

    My approach for this is:

    • using middleware to check for logged-in status and inject it into a context variable.
    • because we need to check authentication for every single loader, I created a Higher-Order Function (HOF) to handle this automatically.

    However, I'm unable to find unstable_dataStrategy in version 7.

  4. infiniteluke commented on Oct 28, 2024

    @infiniteluke
  5. jrmyio commented on Oct 29, 2024

    @jrmyio

    @chasoft https://reactrouter.com/en/main/routers/create-browser-router#middleware

    We do still need a way to be able to change dataStrategy using RR7 vite plugin though.

  6. chinanderm commented on Nov 12, 2024

    @chinanderm

    @infiniteluke Using the new routes.ts pattern, there is nothing similar to RRv6 handle to set up middleware.

  7. added this to the milestone on Jan 6, 2025
  8. removed this from the milestone on Mar 3, 2025
  9. github-actions commented on Mar 6, 2025

    @github-actions
    Contributor

    🤖 Hello there,

    We just published version 7.3.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

    Thanks!

  10. 6 remaining items

  11. moved this from Stage 5 - Stable to Stage 3 - Beta in React Router Roadmapon Jul 23, 2025
  12. removed their assignment
    on Jul 23, 2025
  13. thomasgadsden commented on Jul 25, 2025

    @thomasgadsden

    We've been trying to get unstable_clientMiddleware to run using react-router@7.7.0 with createBrowserRouter (manual routing) in a Vite project. Despite all our efforts, the client middleware never runs. Does unstable_clientMiddleware only work in file-based routing, or are there other steps we need to take to use it with manual routing?

  14. brophdawg11 commented on Jul 25, 2025

    @brophdawg11
    Contributor

    yeah clientMiddleware is a framework-mode thing because that's where the distinction between server and client comes in (loader/clientLoader, middleware/clientMiddleware). For data routers, everything is "client" so there's no distinction. You can just put unstable_middleware: [...] on your route object

  15. thomasgadsden commented on Jul 28, 2025

    @thomasgadsden

    @brophdawg11 thanks for the clarification on this. I changed our code to use unstable_middleware but it still wasn’t working. Eventually, I found some other issues and discussions here and realised that we weren’t defining a loader function on our route-objects – once I added this, everything worked as expected 👍

  16. moved this from Stage 3 - Beta to Stage 4 - Stabilization in React Router Roadmapon Aug 22, 2025
  17. self-assigned this
    on Aug 26, 2025
  18. moved this from Stage 4 - Stabilization to Stage 5 - Stable in React Router Roadmapon Sep 12, 2025
  19. brophdawg11 commented on Sep 12, 2025

    @brophdawg11
    Contributor

    Released as stable in 7.9.0

  20. removed their assignment
    on Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions