How elifnurkarakoc/nextjs-module-federation-playground works
Project type and purpose
• This is a Next.js “Module Federation” playground consisting of two standalone Next.js applications (app1 and app2) configured to explore Webpack’s Module Federation for micro-frontends. Both apps live at the root level and follow identical folder structures with React/TypeScript, TailwindCSS, and Next.js.
File structure
• Top-level:
• .gitignore, README.md
• app1/… (Next.js project)
• app2/… (Next.js project)
• Each app contains:
• Configuration files (.eslintrc.json, next.config.js, tailwind.config.js, tsconfig.json)
• package.json + package-lock.json
• public/ for static assets
• src/components for UI widgets
• src/pages for Next.js routing (including pages/api for serverless endpoints)
• src/styles for global CSS
• No additional “shared” or “common” directory is present—sharing is achieved at runtime via Module Federation.
README for additional insights
• Confirms: “NEXTJS MODULE FEDERATION PLAYGROUND.”
a. Main components
• App1 – Next.js server (Node.js SSR), React app, exposed remote modules
• App2 – Next.js server (Node.js SSR), React app, consumes remote modules (and/or vice versa)
• Shared libraries – React, ReactDOM, Next.js runtime, TailwindCSS utilities
• Browser/Client – initiates requests to each app and dynamically loads federated modules
b. Relationships & interactions
• Client → App1 Node server: initial page request, SSR rendered HTML + federated module manifest
• Client → App2 Node server: same flow, but App2’s pages import components exposed by App1 at runtime (or vice versa)
• Webpack ModuleFederation runtime in the browser resolves and fetches remoteEntry.js files from the other app’s public URL
• Shared chunk negotiation: React and other common libs are deduped/shared between apps
c. Architectural patterns/design principles
• Micro-frontends via Webpack Module Federation
• Next.js SSR + client-side hydration
• Shared dependency deduplication
• Clean separation: each app is independently deployable
d. Key technologies/frameworks
• Next.js with custom next.config.js enabling ModuleFederationPlugin
• React + ReactDOM
• TypeScript
• TailwindCSS (via postcss.config.js)
• ESLint for code quality