A reference implementation of a micro-frontend architecture demonstrating framework-agnostic patterns for building scalable frontend applications.
Live Demo: https://mfe-svelte-shell-example.nathanfox.net
This repository serves as a pattern library for GenAI agents and developers to understand and implement micro-frontend architectures. It demonstrates:
┌───────────────────────────────────────────────────────────┐
│ Shell (Svelte 5) │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Header (auth, user menu) │ │
│ └─────────────────────────────────────────────────────┘ │
│ ┌──────────────┐ ┌────────────────────────────────┐ │
│ │ Navigation │ │ MFE Container │ │
│ │ (from │ │ ┌──────────────────────────┐ │ │
│ │ manifest) │ │ │ React / Vue / Svelte / │ │ │
│ │ │ │ │ etc. (loaded on demand) │ │ │
│ └──────────────┘ │ └──────────────────────────┘ │ │
│ └────────────────────────────────┘ │
│ ┌─────────────────────────────────────────────────────┐ │
│ │ Footer │ │
│ └─────────────────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────┘
mfe-svelte-shell-example/
├── shell/ # Svelte 5 shell application
├── mfes/
│ ├── react-example/ # React 18 micro-frontend
│ ├── vue-example/ # Vue 3 micro-frontend
│ ├── svelte-example/ # Svelte 5 micro-frontend
│ ├── solid-example/ # SolidJS micro-frontend
│ └── angular-example/ # Angular 17+ micro-frontend
├── shared/
│ └── types/ # Shared TypeScript types
└── docs/
├── micro-frontend-architecture.md
├── shell-framework-decision.md
├── mfe-registration-patterns.md
└── state-management-patterns.md
First, install dependencies for each app:
# Install root dependencies (concurrently)
npm install
# Install shell dependencies
cd shell && npm install && cd ..
# Install MFE dependencies
cd mfes/react-example && npm install && cd ../..
cd mfes/vue-example && npm install && cd ../..
cd mfes/svelte-example && npm install && cd ../..
cd mfes/solid-example && npm install && cd ../..
cd mfes/angular-example && npm install && cd ../..
Then start all apps:
# Start shell + all MFEs concurrently
npm run dev
This runs:
Open http://localhost:5000 to see the shell with all MFEs.
# Build all apps and combine into shell/dist
npm run build
The output in shell/dist/ can be deployed to any static hosting (Netlify, Vercel, GitHub Pages, etc.).
Every micro-frontend must export these functions:
export async function bootstrap(props: MfeProps): Promise<void>;
export async function mount(props: MfeProps): Promise<void>;
export async function unmount(props: MfeProps): Promise<void>;
The shell provides these props to every MFE:
interface MfeProps {
container: HTMLElement; // DOM element to render into
basePath: string; // Base route for this MFE
auth: AuthContext; // User, token, login/logout
eventBus: EventBus; // Cross-MFE communication
navigate: (path: string) => void;
theme: 'light' | 'dark';
}
MFEs are registered via manifest.json:
{
"version": "1.0.0",
"mfes": [
{
"id": "react-example",
"name": "React Dashboard",
"entry": "/mfes/react-example/remoteEntry.js",
"route": "/react",
"menu": { "label": "React", "icon": "react", "order": 1 }
}
]
}
| Document | Description |
|---|---|
| MFE Loading Guide | How MFEs load into the shell, requirements, and examples |
| Architecture | Full architecture guide with code examples |
| Shell Framework Decision | Why Svelte 5 for the shell |
| Registration Patterns | Static manifest vs runtime registration |
| State Management | Cross-MFE shared state and caching patterns |
| Troubleshooting | Common issues and solutions (CSS, Svelte 5, Netlify, Angular) |
See shell-framework-decision.md for full analysis.
mfes/shell/public/manifest.jsonSee micro-frontend-architecture.md for detailed examples in React, Vue, Svelte, SolidJS, and Angular.
This repository is designed as a reference for AI coding assistants. Key patterns:
When implementing micro-frontends, follow the patterns in this repository for consistent, maintainable code.
MIT