Micro-Frontends Architecture & Module Federation
Micro-frontends is an architectural style where independently deliverable frontend applications are composed into a unified user interface, primarily solving organizational scaling and team-boundary autonomy.
Why it matters in interviews
Visual & Interactive Explanation
1. User loads Shell Application
Shell loads core layout, global navigation, Auth session, and Design Tokens
2. Route to /checkout
Shell inspects route and fetches Checkout Remote container manifest (remoteEntry.js)
3. Share Singletons
Module Federation verifies React/ReactDOM versions match and shares active singleton instance
4. Mount Remote
Remote Checkout component mounts inside Shell Error Boundary
5. Fault Isolation
If Checkout crashes, Error Boundary catches failure; Shell and Navigation stay alive
Code Examples & Implementation
// Host webpack.config.js (Shell Application)
const { ModuleFederationPlugin } = require('webpack').container;
module.exports = {
plugins: [
new ModuleFederationPlugin({
name: 'shell_app',
remotes: {
checkout: 'checkout_app@https://cdn.example.com/checkout/remoteEntry.js',
dashboard: 'dashboard_app@https://cdn.example.com/dashboard/remoteEntry.js',
},
shared: {
react: { singleton: true, requiredVersion: '^18.2.0', eager: false },
'react-dom': { singleton: true, requiredVersion: '^18.2.0', eager: false },
'@myorg/design-system': { singleton: true },
},
}),
],
};
// React Shell Dynamic Loading with Error Boundary
import React, { Suspense, lazy } from 'react';
import { RemoteErrorBoundary } from './RemoteErrorBoundary';
const RemoteCheckout = lazy(() => import('checkout/CheckoutModule'));
export function CheckoutPage() {
return (
<RemoteErrorBoundary fallback={<p>Checkout service is temporarily unavailable.</p>}>
<Suspense fallback={<div>Loading Checkout Experience...</div>}>
<RemoteCheckout />
</Suspense>
</RemoteErrorBoundary>
);
}Interview-Ready Answers
Micro-frontends split a large monolithic frontend into independently deployable sub-apps integrated via Module Federation or dynamic imports, allowing multiple autonomous engineering teams to ship features independently.
Official Documentation & Specifications
Follow-up Questions & Deep Dives
Common Mistakes & Anti-Patterns
- Adopting micro-frontends for small teams, resulting in massive DevOps overhead and sluggish build pipelines.
- Failing to set singleton: true for React in Module Federation, causing multiple React instances in memory and breaking React Hooks.
- Sharing large Redux stores across micro-frontends, tightly coupling team codebases.
Real-World Architectural Scenario
A company with 80 engineers across 6 domains (Auth, Catalog, Cart, AI Assistant) suffers from 45-minute monolithic deployment queues. How do you design an autonomous micro-frontend transition?
Rate Your Readiness
Rate how comfortably you can explain this in an interview to update your global readiness gauge: