Composition Approaches for Micro Frontends
Explore the main ways micro frontends are composed together — build-time, server-side, and client-side — and learn when to use each.
Composition Approaches for Micro Frontends is a free Micro Frontends Architecture with Module Federation lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Micro Frontends Architecture with Module Federation learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Is Composition?
Composition is how independently built micro frontends combine into the single page a user sees — and your choice shapes performance and deployment.
Three Families of Composition
Composition strategies fall into three families: build-time, server-side, and client-side (run-time). Real systems often mix them.
Build-Time Composition
Build-time composition publishes each MFE as an npm package pulled into a container app. Simple, but it couples deploys — one change rebuilds the whole shell.
{
"dependencies": {
"@team/cart-mfe": "1.2.0",
"@team/search-mfe": "0.9.1"
}
}Server-Side Composition
Server-side composition stitches MFE fragments into one HTML response, giving fast first paint and strong SEO since the browser gets a complete page.
Server-Side Includes (SSI)
A classic technique is Server-Side Includes: include directives the web server replaces with each MFE fragment before sending the page.
<!--#include virtual="/header-mfe" -->
<main><!--#include virtual="/catalog-mfe" --></main>
<!--#include virtual="/footer-mfe" -->Edge-Side Composition
Edge-side composition assembles fragments at the CDN edge (via Edge Side Includes), pairing low latency with centralized stitching close to users.
Client-Side Composition
Client-side composition loads a thin shell, then fetches and mounts each MFE at run time. It is the most flexible approach and the base of Module Federation.
Client-Side with Web Components
One client-side technique wraps each MFE in a custom element (web component). The shell just places the tags and each MFE bootstraps itself.
<app-shell>
<product-list></product-list>
<shopping-cart></shopping-cart>
</app-shell>Trade-offs at a Glance
Each approach trades off: build-time is simplest but weak on independence, server-side nails first load and SEO, client-side maximizes team autonomy.
Choosing an Approach
Choose by priority: server-side when SEO and first paint dominate, client-side for independent deploys and dynamic loading, build-time only for slow-changing teams.
Mixing Strategies
Mature systems mix strategies: server-side render the shell and above-the-fold content, then hydrate or lazy-load interactive MFEs client-side.
Quick Check
Test your understanding of composition.
Recap
Recap: composition can be build-time (coupled), server- or edge-side (great first paint and SEO), or client-side (max independence) — and real systems blend them.
Frequently asked questions
Is the “Composition Approaches for Micro Frontends” lesson free?
Yes — the full text of “Composition Approaches for Micro Frontends” is free to read here on the web, and the Micro Frontends Architecture with Module Federation course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Micro Frontends Architecture with Module Federation course, upgrade to CoddyKit PRO.
What will I learn in “Composition Approaches for Micro Frontends”?
Explore the main ways micro frontends are composed together — build-time, server-side, and client-side — and learn when to use each. You practise Micro Frontends Architecture with Module Federation with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Micro Frontends Architecture with Module Federation?
No prior experience is required. Micro Frontends Architecture with Module Federation on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Composition Approaches for Micro Frontends” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Micro Frontends Architecture with Module Federation lesson?
Yes. Every Micro Frontends Architecture with Module Federation lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- What are Micro Frontends?
- Benefits and Challenges Explored
- Core Concepts & Principles
- Composition Approaches for Micro Frontends