You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use React Router 7 in framework mode (with ssr: false for spa) since I want to keep the advantages of routes config and middleware from the framework.
On the other hand, I would like to make my app structured as a micro-frontend. To do so, I use module federation, and it works well, or maybe until I need to have a router in my modules…
My problem is simple: when using framework mode, I would like to be able to call patchRoutesOnNavigation so I can have lazy discovery for my modules routes. But to do so, some modifications are needed in react-router to allow this.
On the implementation side, i was seeing something similar to what loader and action function are currently doing, but inside the routes.ts file:
// app/routes.tsimport{index}from'@react-router/dev/routes'importtype{RouteConfig,AgnosticPatchRoutesOnNavigationFunction}from'@react-router/dev/routes'exportdefault[index('routes/index.tsx',{id: 'root'})]satisfiesRouteConfigexportconstpatchRoutesOnNavigation: AgnosticPatchRoutesOnNavigationFunction=async({ path, patch })=>{if(path==="/a"){// Load/patch the `a` route as a child of the route with id `root`letroute=awaitgetARoute();// ^ { path: 'a', Component: A }patch("root",[route]);}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I use React Router 7 in framework mode (with ssr: false for spa) since I want to keep the advantages of routes config and middleware from the framework.
On the other hand, I would like to make my app structured as a micro-frontend. To do so, I use module federation, and it works well, or maybe until I need to have a router in my modules…
My problem is simple: when using framework mode, I would like to be able to call
patchRoutesOnNavigation
so I can have lazy discovery for my modules routes. But to do so, some modifications are needed in react-router to allow this.On the implementation side, i was seeing something similar to what
loader
andaction
function are currently doing, but inside theroutes.ts
file:Beta Was this translation helpful? Give feedback.
All reactions