$ next build
ReferenceError: window is not defined
at /apps/Main/.next/server/pages/login.js
Your Next.js host has been running fine. You add one new remote — a React MFE built with ModuleFederationPlugin — and the server build dies on hydration.
The fix is NOT to rewrite the React remote in Next.js. It's to know that a single NextFederationPlugin host can load BOTH plugin types simultaneously. The remote URL pattern alone tells Module Federation which plugin built each remote.
The full guide covers:
-
Dual-plugin host config — one
next.config.jsdeclaring 4 React + 2 Next.js remotes -
URL pattern table —
/auth/remoteEntry.js(React, ONE file) vs/products/_next/static/{ssr|chunks}/remoteEntry.js(Next.js, TWO files) -
The
isServerternary — only on Next.js remotes, never on React ones (no/ssr/folder exists) -
ssr: falsemandatory — even for Next.js remotes that have an SSR entry, because Redux + window -
Bridge pattern —
onNavigateprop keeps React remotes framework-agnostic -
basePath+assetPrefix— prevent/_next/static/chunks/collisions -
Same shared singleton config for both plugins —
@myapp/store,react,redux -
Nginx reverse proxy — static files for React remotes,
proxy_passfor Next.js Node.js processes - 8 production pitfalls with WRONG/FIX side-by-side
Read the full guide with code examples → https://blog.srinudesetti.in/micro-frontend/nextjs/mixing-react-nextjs-micro-frontends
Top comments (0)