Shared Redux Store in Next.js Module Federation: Cross-Remote State
// Auth React remote dispatches:
dispatch(setIsLoggedIn({ isLoggedIn: true }))
// Products Next.js remote reads:
const isLoggedIn = useAppSelector(selectIsLoggedIn)
// β returns FALSE
Enter fullscreen mode Exit fullscreen mode
You log in. Cart still says you didn't.
If you've built a hybrid micro frontend with React remotes (ModuleFederationPlugin) loaded inside a Next.js host (NextFederationPlugin), you have either hit this bug or you will. Open Redux DevTools and you'll see two store instances β one created by the Auth remote, one created by Products. Each remote dispatched into its own copy.
The contract that fixes it
A federated Redux singleton. One @myapp/store package. The host imports it once, creates the store, wraps the app in `. Every remote importsuseSelectoranduseDispatch` from that same package, and Module Federation guarantees they all receive the host's instance β not a fresh one.
What the article covers
- Complete
@myapp/storepackage code βconfigureStore, slices, re-exported react-redux primitives ClientReduxProvider+ssr: falseβ why importing the store at the top of_app.tsxcrashes the server build- The shared block in host
next.config.jsand every remote (webpack.config.jsfor React,next.config.jsfor Next.js) β singleton + strictVersion contract - 5-step Module Federation runtime negotiation β register, dynamic import, version match, reuse
- Real codebase examples β Auth (React) dispatching
setIsLoggedIn, Products (Next.js) readingselectAccessToken - Why each remote keeps its own
ClientReduxProviderβ for standalone dev only - SSR + federated Redux hydration trap β skip SSR for federated state, hydrate on client mount
- 7 gotchas that account for almost every "state is not propagating" bug
- State decision matrix β federated store vs local useState vs URL search params vs TanStack Query
The one debug step that solves 80% of these bugs
Open Redux DevTools. Count the stores. If there is more than one, the singleton negotiation has failed and your shared block has a typo or a missing singleton: true somewhere. Fix that first. Everything else is a waste of time until there is exactly one store in DevTools regardless of how many remotes are mounted.
Read the full guide with code examples β Shared Redux Store in Next.js Module Federation Guide
