Designing the frontend for a suite of apps — micro-frontends with monorepo, module federation, shared authentication, cross-app communication, navigation shells, and design system sharing across an organization.
Micro-FrontendsModule FederationMonorepoSSODesign Systems
0. What Are We Building?
When an organization grows beyond a single product, it ends up managing multiple apps — and designing the frontend for this suite of applications is an enormous engineering challenge. Think of Razorpay with its dashboard at razorpay.com/reports, razorpay.com/payments, razorpay.com/wallets — or Google with maps.google.com, mail.google.com, drive.google.com.
The way you stitch these apps together determines everything about your developer experience: how teams collaborate, how auth flows across apps, how fast you can ship, and whether you can reuse code or end up duplicating it across repositories.
There are two broad categories for a suite of apps. First, apps that live on sub-routes of the same domain — like razorpay.com/reports and razorpay.com/dashboards. Second, apps that live on separate subdomains — like mail.google.com and maps.google.com. Each approach demands a different architectural response.
Key Insight
This article covers both categories. The sub-route pattern typically calls for a monorepo with micro-frontends, shared component libraries, and coordinated deployment. The subdomain pattern leans toward polyrepo with independent teams, SSO-based auth, and looser coupling. Most large organizations end up with a hybrid — and that is what we will design here.
1. Requirements & Scoping
Before choosing an architecture, we need to understand what a suite of apps demands from the frontend. These requirements shape every decision that follows.
Functional
Unified authentication across all apps — single sign-on that works seamlessly
Shared navigation shell that feels like a single cohesive product
Design system and component library shared across all apps
Communication between apps — state, events, and data flow
Independent deployability — each team ships on their own cadence
Non-Functional
Performance — app switching under 200ms, first paint under 1.5s
Isolation — CSS and JS from one app does not leak into another
Scalable — supports 5+ teams, 50+ engineers, 500K+ LOC
The hardest requirement in practice is independent deployability with shared infrastructure. Teams want to ship on their own schedule, but they also want to share auth, navigation, and design tokens. These two goals pull in opposite directions — the architecture is always a compromise between autonomy and cohesion.
2. Architecture Overview — Two Categories
Let me show you the two fundamental approaches before we dive deep into each. The sub-route pattern (Razorpay, Zoho, Salesforce) and the subdomain pattern (Google, Adobe, Microsoft) solve the same problem from opposite ends.
Sub-route architecture — multiple apps hosted on sub-routes of the same domain, sharing auth, store, design system, and utility libraries via monorepo
In the sub-route approach, all apps live under a single domain. The navigation shell is rendered once, auth state is shared in memory, and the monorepo keeps everything version-synced. Each app is a micro-frontend that mounts into a shared layout.
Subdomain architecture — each app is independently owned, often with different tech stacks, connected via SSO, shared cookies, and design tokens
In the subdomain approach, each app is fully independent. They can use different frameworks, deploy on different cadences, and be owned by completely separate teams. The only glue is a shared identity platform and design tokens distributed as a package.
Note
The subdomain approach gives more autonomy but sacrifices code sharing and cross-app communication. The sub-route approach enables deep integration but requires more coordination between teams. There is no universally correct choice — it depends on your organization's size, team structure, and product cohesion goals.
3. Approach A: Micro-Frontend + Monorepo
Micro-frontend architecture is inspired by micro-services on the backend. When multiple teams touch the same frontend codebase, the monolith becomes a bottleneck. Splitting the application into independently developed, independently deployed pieces lets each team move fast without stepping on each other.
The monorepo is the backbone here. A single repository holds all projects, shared libraries, components, and tools. With Turborepo, pnpm workspaces, or Nx, you get cross-project dependency tracking, selective builds, and hoisted dependencies — all without the pain of publishing packages for every shared change.
A well-organized monorepo separates apps from shared packages. Each app is its own deployable unit. Shared packages are versioned together and consumed via workspace aliases — no registry publish required.
Webpack 5's Module Federation plugin is the most mature runtime integration approach for micro-frontends in a monorepo. It lets one app (the shell) consume components from another app (a remote) at runtime — no build-time dependency required.
The shell app declares which modules it exposes and which remotes it consumes. Shared dependencies (React, React DOM, your store library) are configured as singletons — loaded once, shared across all apps.
Module Federation's singleton configuration is the killer feature for micro-frontends. Without it, each micro-frontend bundles its own copy of React — that is 40KB gzip per app, multiplied by the number of apps on the page. With singletons, React is loaded once, and all micro-frontends share the same instance. Same for your auth store, router, and design system context.
Query Cache Layer
A shared query cache (React Query, SWR, or Apollo) provides a single source of truth for server data across micro-frontends. When the dashboard app fetches the user list, the reports app can read from the same cache without a second network request. The query client is configured once in the shell and shared via Module Federation's shared scope.
Warning
Be careful with query key collisions across micro-frontends. Prefix your query keys with the app name to avoid cache poisoning. For example, use ["reports", "analytics"] instead of just ["analytics"].
4. Splitting Strategy — Horizontal vs Vertical
Once you commit to micro-frontends, the next question is how to split your application. You have two fundamental strategies, and they serve very different purposes.
Horizontal Split
In a horizontal split, you slice the view layer. Different teams own different parts of the same page — one team handles the header and navigation, another handles the sidebar, a third owns the main content area. This gives great flexibility because micro-frontends can be composed per-view, but it demands strict governance to prevent an explosion of fragments.
Vertical Split
In a vertical split, you slice by feature domain. The reports team owns everything in the /reports route — page, data fetching, state, components. The payments team owns /payments. This is the more common pattern in production because it gives each team full ownership of a product surface and minimises coordination.
example.txt
┌─────────────────────────────────────────────────┐
│ 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 are easier to reason about, give teams clear ownership boundaries, and avoid the CSS isolation headaches of horizontal composition. Only consider horizontal splits when you have a page that genuinely requires multiple teams to contribute (like a dashboard with widgets from different departments).
5. Micro-Frontend Integration Patterns
There are three mainstream approaches to integrating micro-frontends at runtime. Each makes different tradeoffs in isolation, performance, and developer experience.
Pattern 1: iframe
The original micro-frontend pattern. Each app is an iframe embedded in the shell. It provides the strongest isolation — CSS, JavaScript, and DOM are completely sandboxed. Communication happens viapostMessage. The downside: performance is poor (each iframe loads its own runtime), SEO is difficult, and the user experience feels disjointed.
Pattern 2: Web Components
Each micro-frontend is wrapped in a custom element. The shell renders custom element tags, and the framework-agnostic nature of Web Components means you can mix React, Vue, Angular, and vanilla JS on the same page. Attributes and events handle communication. But sharing complex state (like auth tokens or a cart) requires extra plumbing.
The most sophisticated approach. Apps share a runtime — React is loaded once, the store is a singleton, and components from remote apps feel like local imports. Module Federation handles chunk loading, dependency sharing, and version negotiation at build time. This is the pattern used by large-scale monorepo setups at companies like Shopify and Cloudflare.
Module Federation — host shell manages navigation and shared state; remote apps expose components consumed at runtime without redeployment
example.txt
┌─────────────────────┬──────────┬──────────┬──────────┐
│ │ iframe │ Web │ Module │
│ │ │ Comp. │ Fed. │
├─────────────────────┼──────────┼──────────┼──────────┤
│ Tech-stack freedom │ ✅ Full │ ✅ Any │ Same │
│ │ │ │ bundle │
│ Performance │ ❌ Heavy │ ✅ Lite │ ✅ Fast │
│ Shared context │ ❌ None │ ⚠️ Lim.│ ✅ Full │
│ (auth, store) │ │ │ │
│ SEO │ ⚠️ Poor │ ✅ Good │ ✅ Good │
│ Isolation │ ✅ Full │ ✅ Good │ ⚠️ Lim.│
│ (CSS, JS) │ │ │ │
│ Bundle duplication │ ✅ None │ ⚠️ Some │ ❌ Maybe│
│ Communication │ ✅ Safe │ ✅ Safe │ ✅ Sync │
│ Runtime integration │ ❌ Slow │ ✅ Fast │ ✅ Fast │
│ SSR compatibility │ ❌ No │ ✅ Yes │ ⚠️ Hard │
└─────────────────────┴──────────┴──────────┴──────────┘
Key Insight
Module Federation is the clear winner for sub-route micro-frontends where all apps share the same framework. Use Web Components when different teams insist on different frameworks. Avoid iframes unless you need absolute isolation — for example, embedding a third-party app like a payment gateway or a legacy system you cannot rewrite.
6. Shared Authentication & SSO
Authentication is the first cross-cutting concern you need to solve. Users expect to log in once and be authenticated across all apps in the suite. How you implement this depends on whether your apps live on the same domain or on different subdomains.
Same-Domain Auth (Monorepo / Sub-Route)
When all apps are on the same domain, you can share auth state in memory via a shared store. The auth store lives in a shared package and is instantiated as a singleton via Module Federation. The token is stored in an HttpOnly cookie (set by the server for the entire domain) or in memory with refresh token rotation.
For apps on different subdomains, cookies are the simplest approach. A cookie set with Domain=.google.com is sent to every subdomain request. The auth server sets a session cookie after login, and each app reads it via its own backend. For truly independent domains (youtube.com vs google.com), you need SSO (Single Sign-On) via OAuth or SAML.
example.tsx
// Server response sets cookie for all subdomains
Set-Cookie: session_token=eyJhbGciOiJIUzI1NiIs...;
Domain=.google.com;
Path=/;
HttpOnly;
Secure;
SameSite=Lax;
// Client reads auth state from HttpOnly cookie via API
async function getAuthStatus(): Promise<User | null> {
try {
const res = await fetch("/api/auth/me", {
credentials: "include", // sends cookies cross-origin
});
if (!res.ok) return null;
return await res.json();
} catch {
return null;
}
}
// SSO flow: redirect to identity provider
function loginWithSSO() {
const returnUrl = encodeURIComponent(window.location.href);
window.location.href = `https://accounts.google.com/o/oauth2/auth?
client_id=123&
redirect_uri=${returnUrl}&
response_type=token&
scope=email%20profile`;
}
Warning
When sharing cookies across subdomains, always set the cookie with HttpOnly and Secure flags. Never expose the session token to client-side JavaScript. Also set SameSite=Lax to prevent CSRF while allowing top-level navigation across subdomains.
Token Refresh Strategy
Access tokens expire (typically in 15-60 minutes). A refresh token (stored in an HttpOnly cookie) is used to silently obtain new access tokens. The auth store in each app watches for 401 responses and triggers a refresh before the user notices. In the monorepo setup, the shell manages the refresh cycle and all micro-frontends benefit from the shared token.
The queuing pattern above prevents a "refresh stampede" — when multiple micro-frontends receive 401s simultaneously and all try to refresh the token at once. By queuing concurrent requests and resolving them all with the same fresh token, only one network call is made.
7. Cross-App Communication
Once you split your apps, they need to talk to each other. A user might add an item to the cart in the reports app and expect the cart badge in the shell's navbar to update. Or a logout event in one app should invalidate the session across all open tabs. You need a communication layer.
Six communication patterns for cross-app data flow — postMessage for iframes, shared stores for monorepo micro-frontends, cookies for subdomain auth, localStorage events for cross-tab, custom events for pub/sub, and BroadcastChannel for direct tab-to-tab messaging
Shared Store (Monorepo / Module Federation)
The most natural communication pattern for Module Federation is a shared Zustand or Redux store. All apps import the same store package, and the store instance is a singleton in the shared runtime. When one app dispatches an action, all apps subscribed to that store see the update immediately.
When apps are isolated in iframes or running on different origins,postMessage is the only safe communication channel. The parent sends a structured message to the child, the child responds. Every message handler must validate event.origin — this is not optional.
example.tsx
// Host app sends message to child iframe
function sendToChild(iframeEl: HTMLIFrameElement, type: string, payload: unknown) {
iframeEl.contentWindow?.postMessage(
{ type, payload, source: "host" },
"https://child-app.example.com",
);
}
// Child app listens for messages from host
useEffect(() => {
const handler = (event: MessageEvent) => {
// ALWAYS verify origin
if (event.origin !== "https://host.example.com") return;
const { type, payload } = event.data;
switch (type) {
case "NAVIGATE":
router.push(payload.path);
break;
case "USER_LOGOUT":
authStore.getState().logout();
break;
case "THEME_CHANGE":
document.documentElement.setAttribute("data-theme", payload.theme);
break;
}
};
window.addEventListener("message", handler);
return () => window.removeEventListener("message", handler);
}, []);
// Child sends result back to host
function notifyHost(type: string, payload?: unknown) {
window.parent.postMessage(
{ type, payload, source: "child" },
"https://host.example.com",
);
}
Warning
Never skip the origin check in a postMessage handler. Without it, any website can send messages to your app. Always verify event.origin === "https://your-domain.com" before processing the message. This is the most common micro-frontend security gap I see in production code.
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 state synchronization — login, logout, theme change, cart updates. The store subscribes to storage events and reconciles state using timestamps.
Custom DOM Events (Same-Runtime Apps)
For micro-frontends sharing the same DOM (horizontal split), custom events dispatched on window provide a framework-agnostic pub/sub mechanism. One app dispatches new CustomEvent("cart:updated", { detail: ... })and all listening components react. No shared store required.
Key Insight
My rule of thumb for choosing communication patterns: if apps share the same React runtime (Module Federation), use a shared store. If they are on different origins, use postMessage. If they are on the same origin but independent SPAs, use localStorage events. Custom DOM events are best for loosely-coupled in-page widgets.
8. Navigation Shell & Design System
The navigation shell is the container that wraps all micro-frontends. It provides the header, sidebar, auth guards, and global UI elements that make the suite feel like a single product.
Shell Responsibilities
The shell owns the global layout — navbar, sidebar, notifications toast container, and a content outlet where micro-frontends mount. It also handles authentication: if the user's token is expired, the shell shows the login screen regardless of which micro-frontend the user tried to access.
A shared design system is the single most impactful investment for a suite of apps. It eliminates visual inconsistency, speeds up development, and gives the suite a cohesive brand identity. In a monorepo, the design system lives in packages/ui/and is consumed by all apps via workspace alias.
The key outputs of a shared design system:
Design tokens — CSS custom properties for colors, typography, spacing, and shadows. Published as a CSS file and a JSON file for use in styles and documentation.
Component library — React components (Button, Input, Modal, Select, DataTable) built on the tokens and accessible out of the box.
Icon library — a consistent set of SVG icons exported as React components.
For polyrepo setups where apps use different frameworks, distribute design tokens as platform-agnostic CSS custom properties. Export them from a bare CSS file that any app can import. For React-specific components, publish the design system as an npm package with proper semantic versioning — but be prepared for the publishing overhead. This is where monorepo truly shines over polyrepo.
9. Deployment & Hosting
How you deploy your suite depends on the architecture. For sub-route patterns, you need to serve each micro-frontend's build from the correct path. For subdomain patterns, each app is deployed independently.
Serving Micro-Frontends on Sub-Routes
Each micro-frontend is built as an SPA with a base route set to its sub-route path. The build output is uploaded to a CDN (S3 + CloudFront) in a folder matching the route name. An nginx reverse proxy or an API gateway routes incoming requests to the correct CDN path.
For CloudFront or similar CDNs, configure the origin path to match the sub-route folder. Each app's build goes into a separate S3 prefix, and the CDN serves from that prefix when the corresponding path is requested.
For Module Federation, the remoteEntry.js files must be served with permissive CORS headers if the shell and remotes are on different origins. Add Access-Control-Allow-Origin: * to your CDN response headers for the remote entry files. At runtime, the browser fetches these chunks and loads them into the shared scope.
Subdomain Deployment
For subdomain-based apps, deployment is straightforward — each team deploys independently to their own domain. The DNS setup points each subdomain to the app's hosting provider. No reverse proxy or route orchestration is needed. The only shared infrastructure is the identity provider.
10. Approach B: Polyrepo (Subdomain Pattern)
Not every organization wants or needs a monorepo. Polyrepo — each app in its own repository — is the traditional approach used by Google, Amazon, and many large enterprises. It maximizes team autonomy at the cost of code sharing.
When Polyrepo Makes Sense
Polyrepo works well when teams are fully autonomous, use different tech stacks, or have independent release schedules. Google's suite is a classic example: Gmail (React + Closure), Maps (Angular + WebGL), Docs (CRDT + Canvas), News (React + SSR). Each team chooses the right tool for their problem without coordinating with other teams.
The Cost of Autonomy
The tradeoff is real. In a polyrepo, sharing a library means: develop → test → build → publish to npm → update version in consumer repo → deploy consumer. If you find a bug in the shared library, that loop takes hours instead of minutes. Over time, teams stop sharing and duplicate code, which defeats the purpose of having a suite of apps in the first place.
Key Insight
In my experience, polyrepo works well when the suite is composed of genuinely different products (Google Search is not Gmail). But when apps are closely related — like a dashboard with reports, analytics, and settings — the friction of polyrepo outweighs the autonomy benefits. This is why most SaaS platforms (Razorpay, Shopify, Notion) have converged on monorepo for their core suite.
11. Monorepo vs Polyrepo — Tradeoffs
Let me give you the raw comparison so you can make an informed decision for your organization. There is no universally correct answer — the right choice depends on your team size, product cohesion, and tolerance for coordination overhead.
Choose Monorepo when apps share auth, navigation, and design system
Most SaaS dashboards, admin panels, and internal tools benefit from the tight integration a monorepo provides. The shared infrastructure is worth the coordination cost.
Choose Polyrepo when apps are genuinely independent products
If each app targets a different user base, has its own brand, or uses a fundamentally different tech stack, polyrepo gives teams the freedom they need.
Consider a Hybrid: monorepo for core, polyrepo for edge
Many organizations maintain a monorepo for their primary product suite (auth, dashboard, settings) and polyrepos for auxiliary products (landing pages, marketing sites, docs).
Key Insight
The most successful suite architectures I have seen follow the 80/20 rule: 80% of the value comes from sharing auth, navigation, and the design system. Everything else can be loosely coupled. Start with a monorepo for these three things, and let teams opt out to polyrepo when they genuinely outgrow the coordination model.
12. Key Takeaways
Designing a suite of apps taught me that frontend architecture at scale is more about organizational psychology than technology. The best technical solution fails if it does not fit how your teams work. Here is what I wish I knew before starting:
Auth is the first decision — everything else follows
How users log in determines whether you can share state, whether you need CORS, and how your deployment works. Decide auth first.
Monorepo for shared infra, polyrepo for independence
Keep auth, design system, and navigation in a shared workspace. Let independent features live in their own repos if needed.
Module Federation is the gold standard for micro-frontends
Singleton React, shared stores, and runtime integration make Module Federation the most ergonomic pattern. Web Components are a good fallback for polyglot teams.
postMessage must validate origin — always
This is not negotiable. Without origin validation, any website can inject messages into your micro-frontend communication channel.
Start vertical, split horizontal only when needed
Vertical splits give teams clear ownership. Horizontal splits are for widget-based dashboards where multiple teams contribute to the same page.
Design tokens are the simplest shared investment
A 50-line CSS file with color and spacing variables does more for cross-app consistency than a full component library. Start with tokens, add components later.