Three apps. Three deploys. One page.
Archipelago composes independently built and deployed React apps at runtime with Module Federation 2.0. Clone it, rename it, replace the demo domains — and keep an architecture that already handles shared React, cross-app events, routing, failures and contracts.
npx degit juliocarneiro/archipelago-mfe my-platform - Low-profile keyboard $149
- Wireless mouse $79
- 27" 4K monitor $549
catalog is unavailable right now
The rest of the page keeps working.
The hard parts, already done
Most micro frontend tutorials stop at “the remote rendered”. These are the problems you hit the week after — and how the boilerplate answers each one.
- Two copies of React on the page
- Every shared dependency comes from one config package as a singleton with a real semver range. An E2E test fails if a second React ever appears.
- One remote goes down and the page goes blank
- loaded-first sharing plus an error boundary per app. Only the broken area shows an error with “Try again”; the rest keeps working. Covered by an E2E test.
- Apps need to talk without knowing each other
- A typed event bus on DOM CustomEvent with replay. Props go down, events go up, and each piece of state has exactly one owner.
- Two routers fighting over one URL
- The shell owns prefixes like /catalog/*, each app owns its sub-routes, and a tiny popstate sync keeps both aligned — back button included.
- A deploy silently breaks another team
- Contract-first types for props, events and exposed modules. Breaking a contract fails the typecheck of every consumer in CI.
- CSS from one app restyles another
- Tailwind v4 with one shared theme. Only the shell ships the global reset; remotes ship utilities only.
- Testing a pull request’s remote against production
- A runtime plugin points any remote at another URL from localStorage, behind a host allowlist. No shell rebuild.
- Boundaries erode over time
- ESLint blocks app-to-app imports, CODEOWNERS maps folders to teams, and the PR template carries a contract checklist.
What happens when the page loads
The order matters: shared dependencies are settled first, remotes are fetched only when used, and failures stay inside their island.
- 1
The shell boots and provides shared dependencies
Its entry only runs import("./bootstrap"), giving Module Federation time to set up one React, one design system and one contracts package for the whole page.
- 2
A widget from another app renders in the header
cart/CartBadge is a component-level remote loaded with React.lazy. It runs inside the shell’s React tree, which is why React must be a singleton.
- 3
A route mounts a whole app
Visiting /catalog loads catalog/App through the MF Bridge. The shell calls render() with basename and user; the catalog creates its own React root and router.
- 4
Apps talk through events
“Add to cart” publishes cart:add-requested. The catalog never imports the cart. The cart owns the state, updates it and publishes cart:updated.
- 5
A failure stays local
If a remote cannot be fetched or crashes while rendering, its error boundary shows a contained error. Header, session and the other apps are untouched.
- shell :4000
- Owns
- Layout, top-level routes, session
- Exposes
- nothing — it consumes
- catalog :4001
- Owns
- Product list and detail, /catalog/*
- Exposes
- ./App
- cart :4002
- Owns
- Cart state, /cart/*, header badge
- Exposes
- ./App · ./CartBadge
From clone to running platform in five commands
You need Node.js 22+ and pnpm 11 (corepack picks the version for you). Ports 4000, 4001 and 4002 must be free.
Get the code
GitHub template — click “Use this template” on the repository, then clone yours.
degit — copy the files without the git history:
npx degit juliocarneiro/archipelago-mfe my-platform -
01 Enable pnpm through corepack
corepack enable -
02 Install dependencies
pnpm install -
03 Give it your package scope and project name (add --dry-run to preview)
pnpm init:project --scope @acme --name acme-web -
04 Refresh the lockfile, then lint, typecheck, test and build
pnpm install && pnpm verify -
05 Start every app with hot reload
pnpm dev
Then open
- shellThe composed product — open this one
http://localhost:4000 - catalogStandalone, with a fake signed-in user
http://localhost:4001 - cartStandalone, with a fake-catalog harness
http://localhost:4002
Everyday scripts
-
pnpm --filter @acme/catalog dev - Work on one app alone
-
pnpm test - Unit and component tests (Vitest) in every package
-
pnpm e2e - Playwright against the production builds
-
pnpm verify - lint + typecheck + test + build, before every PR
-
pnpm screenshots - Regenerate the README images
Six conventions that keep the apps independent
The boilerplate is only half the job. These rules are what stop a micro frontend platform from turning back into a monolith.
-
Apps never import other apps
Integrate through Module Federation or a package in packages/. ESLint fails the build otherwise.
-
Contracts are public APIs
Never remove or rename an exposed module, a prop or an event field. Add the new version next to the old one, migrate, then remove.
-
One owner per piece of state
Other apps publish intents like cart:add-requested. Only the owner publishes facts like cart:updated.
-
Remotes ship no global CSS
No reset and no element selectors in federated CSS. Only the page owner — the shell — styles the page.
-
Namespace browser storage
All apps share one origin. Keys look like mfe:<app>:<key>:v<n>.
-
Keep packages/ small
Business logic in a shared package couples every team. Only boundary types, events and infrastructure go there.
A monorepo with independent deploys
One repository for tooling and atomic contract changes; one build, bucket and rollback per app.
apps/
shell/
host: layout, routes, session, boundaries
catalog/
remote: exposes ./App
cart/
remote: exposes ./App and ./CartBadge
packages/
contracts/
types, events, props, event bus
ui/
Tailwind theme + components
mf-config/
shared deps, ports, URLs, CORS
tsconfig/
base TS configs
e2e/
tests that cross boundaries
scripts/
init-project.mjs
docs/
study guide + ADRs
Inside each app
- src/index.ts
- only import("./bootstrap") — async boundary
- src/bootstrap.tsx
- standalone entry, fakes the shell
- src/export-app.tsx
- createBridgeComponent({ rootComponent: App })
- src/styles.css
- federated CSS, no global reset
- rsbuild.config.ts
- name · exposes · shared · port
Each app is a static site
Build each one separately and publish it to its own CDN. The shell learns where the remotes live from two environment variables.
pnpm --filter @acme/catalog build # → apps/catalog/dist
pnpm --filter @acme/cart build # → apps/cart/dist
PUBLIC_CATALOG_URL=https://catalog.example.com \
PUBLIC_CART_URL=https://cart.example.com \
pnpm --filter @acme/shell build # → apps/shell/dist - Cache
- mf-manifest.json and the shell’s index.html with no-cache; hashed files with max-age=31536000, immutable.
- CORS
- Each remote’s host must allow the shell’s origin.
- SPA fallback
- The shell’s host serves index.html for unknown paths so deep links work.
- Rollback
- Republish the previous mf-manifest.json. Assets are immutable, so it takes seconds.
Every decision is written down
The repository includes a study guide that explains why each choice exists and what breaks without it — including the real bugs found while building it.
11 chapters: concepts, Module Federation in depth, communication, contracts, CSS, resilience, testing, deploy, pitfalls and adding a new app.
Open on GitHub → Architecture decision records- 0001 Module Federation 2.0 on Rsbuild
- 0002 One monorepo, independent deploys
- 0003 Typed DOM event bus
- 0004 Contract-first types
- 0005 loaded-first sharing for failure isolation
- 0006 Tailwind v4 with a shared theme
Current, boring where it should be
- Module Federation
- 2.0 · manifest, bridge, runtime plugins
- Rsbuild
- Rspack-based, builds in milliseconds
- React
- 19 · app-level and component-level remotes
- TypeScript
- strict, contract-first types
- Tailwind CSS
- v4 · one shared @theme
- pnpm + Turborepo
- workspaces, cached tasks
- Vitest
- unit, component and contract tests
- Playwright
- E2E against production builds