What are Micro Frontends?
Micro frontends split a web app into independently deliverable frontend apps composed into one product. How they work, integration options and the costs.
What are micro frontends?
Micro frontends are an architectural style where independently deliverable frontend applications are composed into a greater whole. Cam Jackson's article on martinfowler.com uses that wording. It applies the idea behind microservices to the browser: each team owns a slice of the user interface from end to end, builds it, and releases it without coordinating a release of the whole frontend.
How it works
A container application (often called the shell) decides which micro frontend to show and stitches the pieces into one page. The article describes several ways to integrate them:
- Server-side composition. The server assembles HTML from fragments, for example with server-side includes.
- Build-time integration. Each micro frontend is published as a package and bundled into the container. The article advises against it because it forces a lockstep release.
- Run-time integration with iframes. Strong isolation, but routing, deep links and responsive layout get harder.
- Run-time integration with JavaScript. Each micro frontend loads through a script and exposes a function the container calls to mount it. This is the authors' default choice.
- Run-time integration with Web Components. Each micro frontend is a custom element the container creates.
Example
An online shop has a product search team, a checkout team and an account team. The shell renders the header and routes by URL: /search loads the search app, /checkout loads the checkout app. The checkout team can ship a fix in the afternoon while search stays untouched. Each app can even use a different framework, such as React or Vue.js, though that is rarely a good idea.
When it is worth it, and common mistakes
Micro frontends solve an organizational problem: many teams working on one large frontend and blocking each other. The same article lists the costs: duplicated dependencies can increase the download size, development setups can behave differently from the production container, and there are more repositories, pipelines and servers to run. Keeping a consistent user experience across separate codebases is harder, too.
- Adopting them for a small team. A well-structured single app is simpler.
- Splitting by technical layer instead of by business area. Teams then depend on each other again.
- Sharing state through globals. Hidden coupling brings back the monolith. Prefer events or the URL.
- Letting every team pick a different framework. Users then download several runtimes.
- No shared design rules. Buttons and spacing drift apart.
Micro frontends, load testing and monitoring
A page now depends on several bundles and several backends, so the slowest piece sets the pace. Measure each part, not just the shell. Run a load test against the APIs each micro frontend calls, and track API availability and response time in production. Our guide to load testing microservices in the cloud covers the backend side. The related single-page app pattern is what many micro frontends are built from. For the full pattern catalogue, read the original article.
FAQ
What is the difference between micro frontends and microservices?
Microservices split the backend into independent services. Micro frontends apply the same idea to the user interface, so a team can own a feature from the screen down to its service. They are often used together, but each stands on its own.
Do micro frontends need a specific framework?
No. The approach is independent of any framework. The container and the micro frontends only need an agreed way to mount, unmount and communicate.
Are micro frontends bad for performance?
They can be, if each one ships its own copy of shared libraries. Sharing dependencies and measuring page load per route keeps the cost under control.
When should I not use micro frontends?
When one team can comfortably own the whole frontend. The extra pipelines, integration code and consistency work only pay off with several teams that need to release independently.
Related terms
Related LoadFocus Tools
Put this concept into practice with LoadFocus, the same platform that powers everything you just read about.