| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
React micro-frontend reference repo. Two complete demos, same product shape (host shell + two remotes), different integration contracts.
Host shell routes between container-owned Home and two remotes (SubApp1 / SubApp2). Same UX in both folders below.
microfrontend.gif lives at repo root (same asset as master) and is linked from each flow README.
A micro-frontend (MFE) splits a UI into independently built, versioned, and deployable apps that compose into one user experience at runtime.
| Monolith SPA | Micro-frontends |
|---|---|
| One repo, one deploy, one team bottleneck | Multiple apps, independent deploys |
| Shared release train for every change | Teams ship their slice on their schedule |
| One tech lock-in for the whole product | Host + remotes can evolve (with care) |
| Simple mental model | Need clear ownership boundaries + contracts |
Typical use cases
What you still need (non-negotiable)
| Need | Why |
|---|---|
| Node.js 18+ (MF demo prefers 20.19+) | Tooling / Vite / CRA |
| npm 10+ | Workspaces + scripts |
| Modern browser | ESM remotes / CRA bundles |
| Three free ports: 3000, 4001, 4002 | Host + two remotes (do not run both demos at once) |
Optional for production patterns: CDN or static hosting per remote, reverse proxy, CI that builds remotes before/with host.
| Folder | Approach | Best for | Stack |
|---|---|---|---|
| module-federation/ | Module Federation — remoteEntry.js, shared React singleton | New apps, production MF, shared deps | Vite 7 · React 19 · @module-federation/vite · React Router 7 |
| asset-manifest/ | Classic runtime load — asset-manifest.json + script tags + window.render* | Learn original CRA pattern; legacy-style integration | CRA react-scripts 5 · React 18 · react-app-rewired · React Router 6 |
microfrontend-react/
├── README.md ← you are here (strategy + both flows)
├── module-federation/ ← modern Module Federation demo
│ ├── README.md ← deep dive + config
│ ├── container/ ← host
│ ├── sub-app1/ ← remote
│ └── sub-app2/ ← remote
└── asset-manifest/ ← classic asset-manifest demo
├── README.md ← deep dive + config
├── container/ ← host
├── sub-app1/ ← remote
└── sub-app2/ ← remote
| Topic | Module Federation | Asset manifest |
|---|---|---|
| Bundler | Vite | webpack (react-scripts) |
| Contract | remoteEntry.js | asset-manifest.json |
| Load API | import("remote/App") | Inject <script> / <link> + window.render* |
| Shared React | Singleton share scope | Usually separate React copies |
| Best fit | Greenfield + serious multi-team | Teaching / older CRA-shaped apps |
┌─────────────────────────────────────────────┐
│ HOST / SHELL (container) │
│ - layout, nav, auth shell, routing │
│ - decides WHEN to load which remote │
│ │
│ /home → host-owned page │
│ /subapp1 → loads Remote A │
│ /subapp2 → loads Remote B │
└───────────────┬───────────────┬─────────────┘
│ │
▼ ▼
┌───────────┐ ┌───────────┐
│ Remote A │ │ Remote B │
│ own build │ │ own build │
│ own CI │ │ own CI │
└───────────┘ └───────────┘
Host responsibilities: chrome, top-level routes, loading remotes, shared auth token handoff (if any), error boundaries.
Remote responsibilities: feature UI, own data fetching, expose a mount/unmount or federated module, stay runnable standalone.
Shared (decide explicitly): React version policy, design tokens/CSS strategy, router basename, API client/auth.
Use this path when you control greenfield architecture.
Step-by-step in this repo → module-federation/README.md
Same product split, but remotes publish CRA asset-manifest.json and host injects scripts. Fine for understanding runtime composition; prefer Module Federation for new production systems.
Use this path when you already have a SPA (or MPA) and want to extract or embed features.
Goal: keep current app as shell; peel features into remotes over time.
Week 0: [======== Monolith SPA ========]
Week N: [ Shell ] + [ Remote: Settings ] + [ still-monolith rest ]
Later: [ Shell ] + [ Settings ] + [ Checkout ] + [ Admin ]
Goal: embed an already-shipped app inside a new or other shell.
Browser → host JS
→ route /subapp1
→ import("subapp1/App")
→ fetch http://localhost:4001/remoteEntry.js
→ resolve shared react/react-dom
→ execute exposed ./App
→ React renders remote inside host tree
Browser → host JS
→ route /subapp1
→ <MicroFrontend host="http://localhost:4001" name="subapp1" />
→ fetch /asset-manifest.json
→ inject main.css + main.js
→ call window.rendersubapp1("subapp1-container", history)
→ remote createRoot mounts into #subapp1-container
cd module-federation
npm install
npm run devOr from repo root:
npm run install:mf
npm run dev:mfFull docs → module-federation/README.md
cd asset-manifest
npm install
npm startOr from repo root:
npm run install:am
npm run dev:amFull docs → asset-manifest/README.md
Do not run both flows at once — same ports.
| Command | Action |
|---|---|
| npm run install:mf | Install Module Federation workspace |
| npm run install:am | Install asset-manifest workspace |
| npm run install:all | Install both |
| npm run dev:mf / start:mf | Run Module Federation demo |
| npm run dev:am / start:am | Run asset-manifest demo |
| npm run build:mf | Build Module Federation apps |
| npm run build:am | Build asset-manifest apps |
| Situation | Choose |
|---|---|
| New multi-team product | module-federation/ |
| Existing Vite/webpack app, want shared React | Module Federation |
| Teaching / comparing to older blog posts | asset-manifest/ |
| Host bundler hard to change; need quick embed | Asset-manifest style mount API |
| Need strongest long-term ecosystem bet | Module Federation |
| Doc | Contents |
|---|---|
| module-federation/README.md | Architecture, Vite configs, shared deps, prod notes, troubleshooting |
| module-federation/container/README.md | Host-only details |
| module-federation/sub-app1/README.md | Remote 1 |
| module-federation/sub-app2/README.md | Remote 2 |
| asset-manifest/README.md | CRA overrides, manifest loader, window API, troubleshooting |
| asset-manifest/container/README.md | Host + MicroFrontend |
| asset-manifest/sub-app1/README.md | Remote 1 mount API |
| asset-manifest/sub-app2/README.md | Remote 2 mount API |
See LICENSE.
| Back | FazBrowse Home | New Git URL |