Composing independent frontend applications into a cohesive product. iframe, Web Components, Module Federation, single-spa, qiankun — integration patterns, shared dependencies, cross-app communication, styling isolation, and when to use each.
Micro-FrontendsModule Federationsingle-spaqiankun
0. What Are We Building?
Micro-frontends extend the micro-services philosophy to the frontend. Instead of one giant application, you split the UI into independently developed, tested, and deployed pieces that come together at runtime to form a seamless product.
Think of a dashboard like the one at Razorpay: razorpay.com/reports, razorpay.com/payments, razorpay.com/dashboards. Each route loads a different micro-frontend owned by a different team. Or think of the Alibaba ecosystem where qiankun orchestrates dozens of apps across their admin platform.
The challenge is not building the individual apps — it is how you glue them together. Your choice of integration strategy determines everything: whether teams can use different frameworks, how much JavaScript the user downloads, whether CSS leaks between apps, and how fast the user can navigate between them.
Key Insight
This article covers five integration strategies — iframe, Web Components, Module Federation, single-spa, and qiankun — and the cross-cutting concerns that apply to all of them: shared dependencies, cross-app communication, and styling isolation. By the end, you will know which strategy is right for your team.
1. Requirements & Scoping
Micro-frontends solve real organizational problems. Here is what they demand from the frontend architecture.
Functional
Independent develop and deploy — each team ships on their own cadence
Framework agnosticism — teams pick the right tool for their module
Shared navigation and auth — seamless cross-app user experience
Communication between micro-frontends — state, events, navigation
Independent scalability — test, build, and deploy in isolation
Non-Functional
Performance — app switch under 200ms; first meaningful paint under 2s
Isolation — CSS and JS from one micro-frontend must not leak into another
Resilience — one micro-frontend crashing should not take down the entire page
The hardest requirement is independent deployability with shared infrastructure. Teams want to ship on their own schedule but still share auth, navigation, and design system. These goals pull in opposite directions — your integration strategy is always a compromise between autonomy and cohesion.
2. Evolution — From Monolith to Micro-Frontends
Micro-frontends did not appear out of nowhere. They are the result of a decade of frontend teams struggling with the same scaling problems that backend teams faced — and solving them the same way.
Phase 1: The Monolith
A single React/Vue/Angular application. One codebase, one team, one deploy. Works great for startups. Breaks at ~10 engineers.
Phase 2: The Monorepo
Shared code extracted into packages. Turborepo, Nx, or pnpm workspaces enable cross-project dependency management. Teams continue to deploy together but develop in isolation within the same repository.
Phase 3: Micro-Frontends
Each team owns a full page or feature module. They choose their framework, their dependencies, their deployment pipeline. A shell application composes the micro-frontends at runtime. This is where the five integration strategies come in.
Note
Not every organization needs micro-frontends. If your team is under 10 engineers and your application fits in a single repo, a monolith with good modularity is almost always the better choice. Micro-frontends add real complexity — only adopt them when the organizational pain of a monolith becomes unbearable.
3. Integration Strategies
There are five mainstream approaches to integrating micro-frontends at runtime. Each makes different tradeoffs in isolation, performance, framework flexibility, and developer experience.
Five integration strategies for micro-frontends — iframe, Web Components, Module Federation, single-spa, and qiankun — graded by isolation, framework flexibility, and runtime characteristics
Strategy 1: iframe
The original and most isolated micro-frontend pattern. Each app loads in an <iframe> embedded in the shell. CSS, JavaScript, and DOM are fully sandboxed — what happens in the iframe stays in the iframe. Communication happens exclusively via postMessage.
The advantages are straightforward: total isolation, no framework conflicts, and the ability to embed literally any web application. The disadvantages are equally clear: iframes are slow (each loads a full page context), hard to style responsively, invisible to search engines, and break the user's sense of a unified product.
Sandbox attribute — use the sandbox attribute to restrict what the iframe can do. Start with allow-scripts and add capabilities only as needed.
Resize handling — iframes do not auto-size to content. Use postMessage from the child to report its height, then update the iframe element in the shell.
Lazy loading — set loading="lazy" so off-screen iframes do not block initial page load.
Origin validation — every postMessage handler must verify event.origin. This is not optional.
Strategy 2: Web Components
Web Components offer a framework-agnostic integration layer. Each micro-frontend is wrapped in a custom element. The shell renders HTML tags like <mf-widget app-name="reports">, and the custom element class handles mounting, styling, and lifecycle. Behind the scenes, the micro-frontend can use React, Vue, Angular, Svelte, or vanilla JavaScript.
The key feature is Shadow DOM, which provides native CSS scoping. Styles defined inside the shadow root cannot leak out, and global styles outside cannot pierce in (unless the component explicitly exposes parts via ::part()). This makes Web Components the best option for polyglot teams where different micro-frontends use different frameworks.
Lit — Google's lightweight library for building Web Components with reactive properties and template literals. The most popular choice.
Stencil — compiles to standards-compliant Web Components with built-in lazy loading and TypeScript support.
Svelte — compiles components to vanilla JS that can be registered as custom elements.
React — supported via createRoot inside the custom element'sconnectedCallback, but React's event system has known issues with Shadow DOM.
Warning
React's synthetic event system does not work well with Shadow DOM. Events inside the shadow root are retargeted, and React may not propagate them correctly. If your team uses React, consider Module Federation instead of Web Components — or use Lit for Web Components and keep React for the shell.
Strategy 3: Module Federation
Webpack 5's Module Federation plugin is the most sophisticated integration approach for micro-frontends that share the same framework. It enables runtime module loading — one app (the shell) can consume components from another app (a remote) at runtime without a build-time dependency.
The killer feature is singleton shared dependencies. React is loaded once and shared across all micro-frontends. Same for React DOM, your state management library, and your router. This eliminates the bundle duplication problem — without it, each micro-frontend bundles its own copy of React (40KB gzip per app).
Module Federation's shared scope uses a version negotiation algorithm. When the shell declares react: { singleton: true, requiredVersion: "^18.0.0" }, Federation checks the version in each remote's bundle. If all versions are compatible, React is loaded once. If one remote bundles React 17, Federation falls back to loading a separate instance — avoiding a runtime crash at the cost of duplication. This is the safest approach: never force a singleton that would break an app.
Key Insight
Module Federation is the gold standard for micro-frontends in a monorepo where all teams use the same framework. The combination of singleton shared dependencies, runtime integration, and version negotiation makes it the most ergonomic and performant choice. Shopify, Cloudflare, and IKEA use it in production.
Strategy 4: single-spa
single-spa is a JavaScript framework for front-end micro-services. It provides a routing layer that determines which micro-frontend is active based on the current URL, and a lifecycle system that manages the bootstrap, mount, and unmount phases of each app.
Unlike Module Federation, single-spa does not require all apps to share the same framework. You can register React, Vue, Angular, and vanilla applications side by side. Each app exports lifecycle functions, and single-spa calls them at the appropriate time.
Every single-spa micro-frontend must export three lifecycle functions:
bootstrap — called once when the app is first loaded. Use for one-time initialization like fetching configuration.
mount — called when the app becomes active. The app renders into the DOM element provided by the shell.
unmount — called when the user navigates away. The app must clean up DOM, event listeners, and timers.
If an app fails to unmount properly (missed event listener, orphaned DOM, unresolved promise), it causes memory leaks that accumulate over the user's session. single-spa wraps each lifecycle in a timeout and logs errors, but it cannot enforce cleanup.
Routing Model
single-spa intercepts all URL changes and matches them against registered apps. Multiple apps can be active at once (e.g., a navbar that is always active and a content app that matches a specific route). The activity function receives the current location and returns a boolean.
Strategy 5: qiankun
qiankun is a production-ready micro-frontend framework built on top of single-spa by Ant Financial. It takes single-spa's routing and lifecycle system and adds two critical features: a JavaScript sandbox and CSS isolation — both of which are completely absent in vanilla single-spa.
The JS sandbox uses Proxy to intercept global variable access. When a micro-frontend sets window.foo = "bar", qiankun captures that in a sandbox and restores the original state on unmount. This prevents micro-frontends from leaking global variables, patching built-ins, or conflicting with each other.
Unlike single-spa (which requires you to define lifecycle functions in JavaScript), qiankun supports HTML entry. You give it a URL to an HTML file, and qiankun parses it, extracts scripts and styles, and evaluates them inside the sandbox. This means any existing standalone SPA can be turned into a micro-frontend without changes.
Prefetch and Preload
qiankun can prefetch micro-frontends after the main app loads, reducing perceived latency when the user navigates. It supports three prefetch modes: all apps (after idle), matching routes (based on URL patterns), and custom (programmatic control).
Warning
qiankun is heavily optimized for the Chinese enterprise ecosystem. Its documentation and community are primarily in Chinese. If your team is outside that ecosystem, single-spa or Module Federation may be easier to adopt. The sandbox and CSS isolation features are excellent but come with a learning curve.
4. Splitting Strategy — Horizontal vs Vertical
Before choosing an integration strategy, you need to decide how to split your application. The two fundamental approaches serve different organizational needs.
Horizontal Split
You slice the view layer. One team owns the header, another the sidebar, a third the main content. Multiple micro-frontends render on the same page simultaneously. This is the harder approach — it requires strict layout governance, careful CSS isolation, and a shared design system to prevent visual fragmentation.
Vertical Split
You slice by feature domain. The reports team owns everything in/reports — page, data, state, components. The payments team owns /payments. This is the dominant pattern in production because it gives each team full ownership of a product surface and minimises cross-team coordination.
example.text
┌─────────────────────────────────────────────────┐
│ Horizontal Split │
├──────────┬──────────┬──────────┬─────────────────┤
│ Header │ Sidebar │ Content │ Floating Panel │
│ Team A │ Team B │ Team C │ Team D │
├──────────┴──────────┴──────────┴─────────────────┤
│ One page, multiple teams │
├─────────────────────────────────────────────────┤
│ Vertical Split │
├────────────────────────┬────────────────────────┤
│ /reports │ /payments │
│ Team A (full page) │ Team B (full page) │
├────────────────────────┼────────────────────────┤
│ /dashboards │ /settings │
│ Team C (full page) │ Team D (full page) │
└────────────────────────┴────────────────────────┘
Tip
Start with vertical splits. They align with team boundaries, simplify CSS isolation (each page is a separate app), and reduce the coordination burden. Only consider horizontal splits when a single page genuinely requires multiple teams — like a dashboard with widgets from different departments.
5. Shared Dependencies & Runtime
One of the first questions teams face: should micro-frontends share dependencies or bundle their own? The answer depends on your integration strategy and your tolerance for bundle size vs isolation.
Singleton vs duplicated dependency model — the bundle size difference grows linearly with the number of micro-frontends
Singleton Model
Module Federation is the only strategy that natively supports singleton shared dependencies. React, React DOM, your store library, and your router are loaded once and shared across all micro-frontends. The version negotiation ensures compatibility. Bundle savings are dramatic: 5 micro-frontends sharing React load about 2MB total vs 5MB if each bundles its own copy.
Duplicated Model
iframes always duplicate dependencies — each iframe is a full page load with its own runtime. Web Components and single-spa can share dependencies if the shell loads them first and the micro-frontends consume the global version, but this is fragile: if one app accidentally bundles React, you now have two copies.
Shared Store Pattern
When micro-frontends share the same runtime (Module Federation), a shared Zustand or Redux store provides a single source of truth for cross-cutting state like auth, theme, and notifications. The store is configured as a singleton dependency and all apps import the same instance.
example.typescript
// packages/shared-store/src/authStore.ts
import { create } from "zustand";
import { subscribeWithSelector } from "zustand/middleware";
interface AuthState {
user: User | null;
token: string | null;
isAuthenticated: boolean;
login: (email: string, password: string) => Promise<void>;
logout: () => void;
refreshToken: () => Promise<void>;
}
export const useAuthStore = create<AuthState>()(
subscribeWithSelector((set) => ({
user: null,
token: null,
isAuthenticated: false,
login: async (email, password) => {
const res = await fetch("/api/auth/login", {
method: "POST",
body: JSON.stringify({ email, password }),
});
const { user, token } = await res.json();
set({ user, token, isAuthenticated: true });
},
logout: () => {
set({ user: null, token: null, isAuthenticated: false });
},
refreshToken: async () => {
const res = await fetch("/api/auth/refresh", {
credentials: "include",
});
if (res.ok) {
const { token } = await res.json();
set({ token });
}
},
})),
);
// All micro-frontends import the same store
// Shell and remote both have access to useAuthStore
// Auth state is shared synchronously across all apps
Key Insight
If your micro-frontends share the same framework and you care about bundle size, Module Federation is the only real option. The singleton dependency model saves 30-50% of total JavaScript bytes compared to iframes or standalone deployments. If you need cross-framework support, Web Components or single-spa are better choices — but accept the bundle duplication cost.
6. Cross-App Communication
Micro-frontends need to talk to each other. A login in one app must propagate to all others. A theme change should be reflected everywhere. The communication mechanism depends on your integration strategy.
postMessage (iframes / Cross-Origin)
When micro-frontends are isolated in iframes or running on different origins, postMessage is the only safe communication channel. The shell sends a structured message, the child validates the origin and processes it. Every handler must check event.origin.
example.typescript
// Shell sends message to micro-frontend
function sendToMicroFrontend(iframeEl, type, payload) {
if (!iframeEl.contentWindow) return;
iframeEl.contentWindow.postMessage(
{ type, payload, source: "shell" },
"https://child-app.example.com",
);
}
// Micro-frontend listens
window.addEventListener("message", (event) => {
if (event.origin !== "https://shell.example.com") return;
const { type, payload } = event.data;
switch (type) {
case "USER_LOGIN":
authStore.login(payload.token);
break;
case "THEME_CHANGE":
document.documentElement.dataset.theme = payload.theme;
break;
case "NAVIGATE":
router.push(payload.path);
break;
}
});
// Micro-frontend replies
function notifyShell(type, payload) {
window.parent.postMessage(
{ type, payload, source: "child" },
"https://shell.example.com",
);
}
Custom DOM Events (Same-Runtime Shared DOM)
For micro-frontends sharing the same DOM (horizontal split, Web Components, single-spa), custom events dispatched on window provide a framework-agnostic pub/sub mechanism. One app dispatches an event, all listening components react. No shared store required.
Shared Store (Module Federation / Singleton Runtime)
When all apps share the same JavaScript runtime, a shared store is the most natural communication pattern. Zustand, Jotai, or Redux instances are configured as singletons and imported by all micro-frontends. Mutations in one app propagate instantly to all listeners.
qiankun Global State
qiankun provides initGlobalState for cross-app communication. The shell initializes a global state object, and every micro-frontend receives onGlobalStateChange and setGlobalState as props. This is similar to a shared store but built into the framework.
localStorage Events (Cross-Tab)
When a user has the suite open in multiple tabs, the storage event fires in all tabs except the one that wrote to localStorage. This is the best mechanism for cross-tab synchronization — login, logout, theme changes, cart updates.
Key Insight
Choosing the right communication strategy: shared store for Module Federation, postMessage for iframes, custom events for Web Components and single-spa, global state for qiankun. Every strategy must handle the auth flow first — that is the most critical cross-cutting concern.
7. Styling Isolation
CSS leaking between micro-frontends is one of the most painful problems in production. One team adds a global style for h1 and suddenly another app's headings look wrong. There are four main approaches to preventing this, and production systems typically use a combination.
Styling isolation strategies for micro-frontends — each approach works at a different layer; production systems combine multiple strategies
1. CSS Modules
CSS Modules generate unique class names at build time. The class.widget becomes .Widget_widget__3xK9a, guaranteeing no collisions across micro-frontends. This is the simplest and most performant approach — zero runtime overhead. Works with any build tool (Webpack, Vite, Turbopack) and is compatible with Module Federation, single-spa, and qiankun.
Web Components provide native CSS isolation via Shadow DOM. Styles defined inside a shadow root are scoped to that root — they cannot leak out, and external styles cannot pierce in. The child can expose styling hooks via CSS custom properties (inherited through the shadow boundary) and ::part() pseudo-elements.
example.typescript
// Shadow DOM isolates styles completely
// Shell CSS cannot pierce in; child CSS cannot leak out
// Child creates closed shadow root
const host = document.getElementById("mf-root");
const shadow = host.attachShadow({ mode: "closed" });
// Styles only affect this shadow tree
shadow.innerHTML = `
<style>
h1 { color: red; } /* only inside this shadow */
.card { padding: 16px; } /* only inside this shadow */
</style>
<div class="card">
<h1>Isolated Content</h1>
</div>
`;
// Shell CAN style shadow host itself
host.style.border = "1px solid #ccc";
// Shell CANNOT style shadow internals
// unless child exposes ::part()
// .card { background: blue; } ← NOT applied
// Child can expose parts for theming
// <div class="card" part="card">...</div>
// ::part(card) { background: blue; } ← works
3. CSS-in-JS
Libraries like emotion and styled-components generate unique class names at runtime, scoping styles to the component. This works well within a single framework but can cause issues when multiple instances of the CSS-in-JS runtime are active (e.g., two React roots in the same page). The runtime overhead is small but measurable — typically 2-5KB per instance plus SSR complexity.
4. PostCSS Prefix / BEM
A PostCSS plugin (like postcss-prefix-selector) automatically prefixes all selectors with a namespace, e.g., all classes in the reports app become .reports-*. This is a build-time operation with zero runtime cost. Combined with a naming convention like BEM, it provides predictable scoping without the overhead of Shadow DOM or the dependency on a specific framework.
Layered Isolation Strategy
No single technique is sufficient for production. The recommended layered approach:
Layer 1: Design tokens — CSS custom properties define colors, spacing, and typography. All micro-frontends use the same tokens. This provides visual consistency without isolation.
Layer 2: Build-time scoping — CSS Modules or PostCSS prefix prevent class name collisions. This is the first line of defense.
Layer 3: Runtime scoping — Shadow DOM (for Web Components) or qiankun's experimentalStyleIsolation provides a second barrier.
Layer 4: CSP — Content Security Policy with strict nonces prevents style injection attacks and limits which stylesheets can load.
Warning
qiankun's experimental CSS isolation wraps each micro-frontend's styles in a scope attribute, but it does not handle dynamically injected styles (e.g., CSS-in-JS). Test thoroughly if your micro-frontend uses runtime style injection.
8. Comparison Table
Here is the raw comparison across all five integration strategies. Use this as a reference when evaluating which approach fits your team's constraints.
example.text
┌──────────────────────┬───────────┬──────────────┬────────────────┬───────────┬──────────┐
│ │ iframe │ Web Comp. │ Module Fed. │ single-spa│ qiankun │
├──────────────────────┼───────────┼──────────────┼────────────────┼───────────┼──────────┤
│ Tech-stack freedom │ ✅ Full │ ✅ Any │ ❌ Same │ ✅ Any │ ✅ Any │
│ │ │ framework │ framework │ │ │
│ Performance │ ❌ Heavy │ ✅ Lite │ ✅ Fast │ ✅ Fast │ ✅ Fast │
│ CSS isolation │ ✅ Full │ ✅ Shadow │ ⚠️ Module │ ⚠️ Manual│ ✅ Sbx │
│ JS isolation │ ✅ Full │ ⚠️ Polyfill │ ❌ Shared │ ❌ Shared│ ✅ Prxy │
│ Shared context │ ❌ None │ ⚠️ Limited │ ✅ Full │ ✅ Props │ ✅ Glbl │
│ SEO │ ⚠️ Poor │ ✅ Good │ ✅ Good │ ✅ Good │ ✅ Good │
│ SSR compat │ ❌ No │ ✅ Yes │ ⚠️ Hard │ ✅ Yes │ ⚠️ Hard │
│ Bundle duplication │ ✅ None │ ⚠️ Some │ ✅ Singleton │ ⚠️ Some │ ⚠️ Some │
│ Learning curve │ ✅ Low │ ⚠️ Medium │ ❌ High │ ❌ High │ ❌ High │
│ Production use │ ✅ Wide │ ✅ Moderate │ ✅ Growing │ ✅ Wide │ ✅ CN │
│ Community size │ ✅ Huge │ ✅ Large │ ✅ Large │ ⚠️ Small │ ⚠️ Niche│
│ Communication │ ✅ Safe │ ✅ Safe │ ✅ Sync │ ⚠️ Props │ ✅ Glbl │
└──────────────────────┴───────────┴──────────────┴────────────────┴───────────┴──────────┘
What the Table Tells Us
iframe — strongest isolation but worst performance and UX. Use only for third-party embeds (payment gateways, legacy apps, external widgets).
Web Components — the best cross-framework option. Shadow DOM provides CSS isolation. Good performance. The complexity comes from React's Shadow DOM limitations.
Module Federation — the best option when all teams use the same framework. Singleton dependencies save bandwidth. Version negotiation prevents breaking changes.
single-spa — proven routing and lifecycle orchestration. Cross-framework support. But no built-in sandbox or CSS isolation — you must handle those yourself.
qiankun — single-spa with production-grade sandbox and isolation. Excellent for enterprise adoption. The ecosystem is primarily Chinese.
Key Insight
There is no universally "best" strategy. The right choice depends on your team's framework preferences, isolation requirements, performance targets, and ecosystem constraints. The good news: you can mix strategies within the same shell. Use Module Federation for React apps, Web Components for legacy systems, and iframes for third-party embeds — all in the same navigation shell.
single-spa and qiankun deserve a deeper look because they are the only strategies that are entire frameworks rather than patterns. They provide routing, lifecycle management, and (in qiankun's case) a full sandbox.
single-spa Architecture
single-spa operates as a routing layer sitting above all micro-frontends. It listens to popstate events and URL changes, runs activity functions to determine which apps should be active, and calls their lifecycle methods. The shell application is typically a lightweight HTML page with a root config that registers all apps.
Utility Modules
single-spa supports shareable utility modules — libraries that are loaded once and consumed by multiple micro-frontends. This is analogous to Module Federation's shared scope but implemented via SystemJS imports. Common utility modules include the auth client, design system, and API middleware.
Integration with Module Federation
single-spa and Module Federation are not mutually exclusive. You can use single-spa for routing and lifecycle management while using Module Federation for shared dependencies and remote module loading. This is a powerful combination: single-spa handles "which app is active" and Module Federation handles "how to load and share code".
qiankun Sandbox Deep Dive
qiankun's sandbox is the most sophisticated isolation mechanism among all strategies. It uses a Proxy to intercept global object access on window. When a micro-frontend attaches a global variable or patches a built-in method, the proxy records the change. On unmount, qiankun restores every property to its original value.
The sandbox operates in three modes:
Strict — each micro-frontend gets a completely isolated proxy window. Global changes are never visible to other apps. This is the safest mode but requires the most memory.
Legacy — uses a diff-based approach. Records all modifications during mount and reverts them on unmount. Less memory but can miss changes made by asynchronous code.
Disabled — no sandbox. Use only when you fully trust all micro-frontends (rarely recommended).
Note
The sandbox adds overhead. Each property access on the proxy window has a small cost, and qiankun intercepts all of them. In practice, the overhead is negligible for most apps (1-3% performance impact), but if your micro-frontend does heavy DOM manipulation or tight loops, benchmark before enabling strict mode.
Qiankun's Styling Isolation
Qiankun provides two CSS isolation strategies:
Experimental Style Isolation — wraps each micro-frontend's stylesheet in a scope attribute, effectively simulating scoped styles. This works by overriding HTMLStyleElement to add a scope selector.
Strict Style Isolation — uses Shadow DOM for the micro-frontend container. Complete CSS encapsulation but may break UI frameworks that rely on global styles (like Ant Design's modal portal).
10. Deployment & Hosting
How you deploy micro-frontends depends on your integration strategy and whether apps live on sub-routes or subdomains.
Each micro-frontend is built as an SPA with a basename matching its sub-route. Builds are uploaded to a CDN, and a reverse proxy (nginx, CloudFront) routes requests to the correct path. For Module Federation, the remoteEntry.js files must be served with CORS headers if the shell and remotes are on different origins.
example.text
server {
listen 80;
server_name app.example.com;
# Route to CDN-hosted micro-frontend builds
location /reports {
proxy_pass https://cdn.example.com/reports/;
proxy_set_header Host cdn.example.com;
}
location /dashboards {
proxy_pass https://cdn.example.com/dashboards/;
}
location /payments {
proxy_pass https://cdn.example.com/payments/;
}
# API gateway
location /api/ {
proxy_pass https://api.example.com/;
}
}
// Each SPA sets basename in its router
function App() {
return (
<BrowserRouter basename="/reports">
<Routes>
<Route path="/" element={<Dashboard />} />
</Routes>
</BrowserRouter>
);
}
Subdomain Deployment (any strategy)
Each micro-frontend deploys independently to its own subdomain. No reverse proxy needed — DNS handles routing. Auth is shared via cookies with Domain=.example.com or SSO via OAuth.
Here is a practical framework for choosing your integration strategy based on your team's constraints.
Single framework (React/Vue/Angular) + monorepo? Use Module Federation
Best bundle efficiency, shared singletons, native runtime integration. The de facto choice for SaaS dashboards and admin panels.
Multiple frameworks across teams? Use Web Components or single-spa
Web Components for framework-agnostic components within the same page. single-spa for route-level isolation with different SPAs.
Need full JS and CSS sandbox? Use qiankun
The only strategy with production-grade sandboxing. Ideal for large enterprises where micro-frontends from different vendors must coexist without conflict.
Embedding third-party or legacy apps? Use iframe
When you have no control over the embedded app (payment gateway, legacy PHP app, external dashboard), iframe provides the isolation you need.
Need to combine strategies? Mix them in the same shell
Module Federation for React apps, iframe for legacy embeds, Web Components for shared widgets. Most large organizations end up with a hybrid approach.
Key Insight
The most successful micro-frontend architectures I have seen start with one strategy and add others as needs evolve. Starting with Module Federation for your core apps and adding iframes for legacy systems is a common and practical progression. Avoid the temptation to design a perfect five-strategy system on day one.
12. Key Takeaways
Micro-frontends are a powerful architecture, but they introduce real complexity. Here is what I learned designing these systems in production.
Design auth first — it determines everything else
Auth strategy dictates whether you can share state, need CORS, and how deployment works. Decide auth before choosing an integration strategy.
CSS isolation is the hardest production problem
Layer multiple strategies: design tokens + CSS Modules + Shadow DOM + CSP. No single technique is sufficient at scale.
Module Federation is the gold standard for same-framework teams
Singleton React, shared stores, and runtime loading make Module Federation the most ergonomic pattern. Use it if your teams agree on a framework.
Always validate postMessage origin
Without origin validation, any website can inject messages into your micro-frontend communication. This is the most common security gap in production.
Start vertical, split horizontal only when necessary
Vertical splits give teams clear ownership of a route. Horizontal splits are for widget dashboards where multiple teams contribute to the same page.
Not every team needs micro-frontends
If you have fewer than 10 engineers, a well-structured monolith with good component boundaries will serve you better. Micro-frontend complexity is justified when organizational scaling demands it.