Navigation sync between isolated createBrowserRouter instances using createBridgeComponent #4284
Unanswered
MatejFacko
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm facing a synchronization issue in a Module Federation setup using @module-federation/bridge-react.
Architecture:
Host: Uses createBrowserRouter with RouterProvider.
Remotes: Each remote is exported via createBridgeComponent and maintains its own createBrowserRouter.
Constraint: I am NOT using react-router-dom as a singleton in the shared configuration because I want to maintain strictly nested/isolated router instances.
The Issue: I have a CustomEvent bus to communicate navigation requests from Remote to Host.
Remote dispatches "navigate to /page-b".
Host captures this and calls its own Maps('/page-b').
The Browser URL updates correctly.
Problem: The Host UI updates (if it has matching routes), but the Remote UI (rendered via Bridge) stays frozen on the previous state and doesn't re-render its internal routes.
Technical question: Since the Bridge creates a separate React root, how should I propagate the Host's location change down to the Remote's createBrowserRouter without making the library a singleton?
Is there a built-in way in createBridgeComponent to "push" a location update so the internal data router of the remote triggers a re-render? Or is createBrowserRouter in Remotes fundamentally incompatible with this "No-Singleton" approach due to context isolation?
Beta Was this translation helpful? Give feedback.
All reactions