Skip to main content
← Back to Blog
2026-02-21 · 9 min readWeb DevelopmentUpdated Oct 29, 2026

Introduction to Micro Frontends: Building Scalable Architectures

An honest introduction to micro frontends: the problem they solve, the integration options and their trade-offs, a working webpack Module Federation setup with a host and a remote, communication through browser events and the URL, and the costs in payload, styling and operations. The two-app example was built with webpack 5.112 and clicked through in a browser.

Avnish Yadav
AI Automation Engineer & Salesforce Developer
24 views
Introduction to Micro Frontends: Building Scalable Architectures

When many teams work on one frontend, they start to block each other. A change to billing waits for a release that also carries a risky change to search. Micro frontends split the frontend so each team can build and ship its part alone. This guide is for developers and leads who keep hearing the term and want to know what it means in practice. You'll compare the integration options, wire two apps together with webpack Module Federation, and see the costs.

This is part 29 of the Frontend & JavaScript Fundamentals series. The previous part, frontend deployment strategies, covered how one app reaches production. Here, several apps do, on their own schedules. The webpack config builds on the build pipeline part.

Key takeaways

  • Micro frontends solve a team problem: independent releases. If one team owns the frontend, a well-split single app is simpler.
  • Run-time integration, for example with Module Federation, lets a team deploy without the host rebuilding. Build-time integration as npm packages doesn't.
  • Keep communication between apps small: browser events and the URL, not a shared global store.

What micro frontends are

Micro frontends are "an architectural style where independently deliverable frontend applications are composed into a greater whole," in the words of the article on martinfowler.com. Each part of the product, such as search, product details or checkout, becomes its own app. The team that owns it also owns its repository, build and release.

micro-frontends.org lists a few core ideas. Three are worth knowing from day one:

  • Isolate team code. Don't share a runtime, even if all teams use the same framework. No shared global state.
  • Use team prefixes. Agree on names for CSS classes, events and storage keys, so they don't collide.
  • Build a resilient site. A feature should still be useful when its JavaScript fails or hasn't run yet.

The same site says teams can choose different frameworks. As a rule of thumb, mixing frameworks costs more than it saves unless you are migrating old code, because each framework adds to the download.

Three ways to put the pieces together

The hard part is composing the apps into one page. The martinfowler.com article describes these options.

Build-time integration

Each micro frontend is published as an npm package, and a container app installs them all. It looks tidy, but the article warns that it creates a "lockstep release process". A change to checkout still means rebuilding and releasing the container. You get separate code, not separate releases.

Server-side composition

The server assembles HTML fragments before it sends the page. nginx can do this with its SSI module, for example <!--# include virtual="/checkout/fragment" -->. Tools such as Zalando's Tailor did it in Node.js, though its repository was archived in December 2022. This approach is good for first paint, but your teams now share a server layer.

Run-time integration

The container, often called the shell or host, loads each micro frontend in the browser. Options include iframes, a JavaScript entry function, and Web Components. The martinfowler.com article calls the JavaScript approach the most flexible. Module Federation is a webpack feature for this style.

Approach What it does Trade-off When to use
Build-time (npm packages) Bundles every part into the container Releases happen in lockstep Shared component libraries, not micro frontends
Server-side composition Server stitches HTML fragments Good first paint; shared server layer Content-heavy pages, SEO-critical routes
Run-time (Module Federation, JS, Web Components) Browser loads each part on demand More requests; versions must stay compatible Teams that need independent releases

Module Federation in practice

webpack's docs describe Module Federation as multiple separate builds forming a single application. A remote exposes modules. A host loads them at run time, as if they were local imports.

The example below has two apps. The checkout remote exposes a buy button. The shell host shows a cart counter and loads the button. Both need webpack, webpack-cli, webpack-dev-server and html-webpack-plugin as dev dependencies. React is optional: nothing here imports it, and both apps built without it. Install it only if your apps use the shared React entries.

The remote: checkout

The exposed module is plain JavaScript, so any host can mount it, whatever framework the host uses:

// checkout/src/BuyButton.js
export function mountBuyButton(element, { sku }) {
  const button = document.createElement('button');
  button.type = 'button';
  button.textContent = 'Add to cart';

  button.addEventListener('click', () => {
    window.dispatchEvent(
      new CustomEvent('checkout:cart-updated', { detail: { sku, added: 1 } })
    );
  });

  element.append(button);
  return () => button.remove(); // lets the host unmount it
}
// checkout/src/index.js: lets the team run checkout on its own
import { mountBuyButton } from './BuyButton.js';

mountBuyButton(document.body, { sku: 'demo' });
// checkout/webpack.config.js (the remote)
const { ModuleFederationPlugin } = require('webpack').container;
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  devServer: {
    port: 3011,
    // let the shell on another port load remoteEntry.js and its chunks
    headers: { 'Cross-Origin-Resource-Policy': 'cross-origin' },
  },
  plugins: [
    new ModuleFederationPlugin({
      name: 'checkout',
      filename: 'remoteEntry.js',
      exposes: {
        './BuyButton': './src/BuyButton.js',
      },
      shared: {
        react: { singleton: true, requiredVersion: '^19.0.0' },
        'react-dom': { singleton: true, requiredVersion: '^19.0.0' },
      },
    }),
    new HtmlWebpackPlugin({ title: 'Checkout' }),
  ],
};

The shared block is for teams that use React. The plugin reference says singleton allows only one copy of a library in the shared scope. That matters for libraries with global internal state, such as react and react-dom. requiredVersion states which versions this app accepts.

The dev server blocks other origins by default

In a test run, webpack-dev-server 6 answered remoteEntry.js with Cross-Origin-Resource-Policy: same-origin, and the browser refused to load it from the shell on port 3012. The cross-origin value in the config above allows it. In production, set the headers your CDN needs for the shell's domain.

The host: shell

The shell's entry does only one thing: it imports the real start-up code. webpack's Module Federation page strongly recommends this asynchronous boundary. Without it, a host that shares modules can fail with "Shared module is not available for eager consumption".

// shell/src/index.js: the async boundary
import('./bootstrap.js');
// shell/src/bootstrap.js
const count = document.getElementById('cart-count');
const slot = document.getElementById('buy-slot');
let total = 0;

window.addEventListener('checkout:cart-updated', (event) => {
  total += event.detail.added;
  count.textContent = String(total);
});

import('checkout/BuyButton')
  .then(({ mountBuyButton }) => mountBuyButton(slot, { sku: 'tea-01' }))
  .catch(() => {
    slot.textContent = 'Checkout is unavailable right now. Please try again later.';
  });
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Shop</title>
  </head>
  <body>
    <header>Cart: <span id="cart-count">0</span></header>
    <main id="buy-slot"></main>
  </body>
</html>

Save the HTML as shell/src/template.html. Then the host config:

// shell/webpack.config.js (the host)
const { ModuleFederationPlugin } = require('webpack').container;
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  devServer: { port: 3012 },
  plugins: [
    new ModuleFederationPlugin({
      name: 'shell',
      remotes: {
        checkout: 'checkout@http://localhost:3011/remoteEntry.js',
      },
      shared: {
        react: { singleton: true, requiredVersion: '^19.0.0' },
        'react-dom': { singleton: true, requiredVersion: '^19.0.0' },
      },
    }),
    new HtmlWebpackPlugin({ template: './src/template.html' }),
  ],
};

Checked against webpack@5.112.2, webpack-cli@7.2.3, webpack-dev-server@6.1.0 and html-webpack-plugin@5.6.8 on Node.js 22.23.2, 2026-10-29. Neither config sets mode, so pass it on the command line: npx webpack --mode production builds each app, and npx webpack serve --mode development runs it. In a test run with both dev servers up, opening http://localhost:3012 and clicking the button updated the counter. With the checkout server stopped, the shell showed the fallback message.

Two things in this code are deliberate:

  • The remote import can fail. If checkout is down, import('checkout/BuyButton') rejects. The .catch() keeps the rest of the page working, which is the "resilient site" idea in action.
  • The remote URL is hard-coded for local work. As a rule of thumb, read it from build-time config per environment, so staging and production point at the right checkout build.

With this setup, the checkout team ships a new remoteEntry.js, and the shell picks it up on the next page load without a rebuild. That only works if remoteEntry.js is served with no-cache, like index.html in the deployment part, because its name doesn't change between releases. That is the independent release you were after.

How micro frontends talk to each other

Once the apps are split, you can't pass props across them. Keep communication small and loose. Both main sources point to the same tools.

  1. Browser events. The buy button above dispatches a CustomEvent, and the shell listens on window. MDN documents the detail option that carries the data. micro-frontends.org advises using browser events instead of a custom global pub/sub system.
  2. The URL. For navigation, the URL is shared state that every app can read. The martinfowler.com article lists it as a way to coordinate without direct dependencies.

Avoid a shared global store, such as one Redux store for every app. The martinfowler.com article advises against shared state, because it ties the apps back together.

// Avoid: checkout reaches into the shell's store
window.appStore.dispatch({ type: 'cart/add', sku });

// Prefer: checkout announces what happened, and anyone may listen
window.dispatchEvent(
  new CustomEvent('checkout:cart-updated', { detail: { sku, added: 1 } })
);

Note the checkout: prefix on the event name. That is the team-prefix idea from micro-frontends.org.

The trade-offs

The martinfowler.com article is frank about the costs.

  1. Payload size. Apps built separately can each include the same libraries, so users may download more. Shared modules reduce this but don't remove it.
  2. Styling. CSS is global, so one team's h1 { color: blue } can change another team's page. Use team prefixes, CSS Modules or Shadow DOM so each team's styles stay its own.
  3. Environment differences. An app that works on its own may behave differently inside the shell, with its global styles and scripts.
  4. Operations and governance. More repositories, pipelines and servers mean more to run. The article says teams need the maturity to handle that.

Fixed in this version

The earlier version left out the async boundary that webpack recommends for hosts that share modules. The Tailor link also pointed to the wrong repository.

When to use micro frontends

They answer an organizational question more than a technical one. Consider them when several teams own clear parts of one product and release coordination is slowing everyone down. Skip them for a personal project, a startup's first version, or any frontend that one team owns. There, a single app split into clear modules and lazy-loaded routes gives most of the benefit for far less work.

Next in the series, the path from junior developer to tech lead looks at the skills behind decisions like this one.

Frequently asked questions

Are micro frontends the same as microservices?

They follow the same idea, applied to the frontend. Each team owns a slice from the user interface down, and releases it on its own. The difference is that the pieces still have to meet on one page in the user's browser.

Do all teams have to use the same framework?

No, but it usually helps. micro-frontends.org lists being technology agnostic as a core idea. In practice, each extra framework adds download size, so mixed stacks make most sense during a migration.

What does "Shared module is not available for eager consumption" mean?

The host's entry tried to use a shared module before Module Federation had loaded it. Move your start-up code into a bootstrap.js file and load it with import('./bootstrap.js'), as webpack's Module Federation page recommends.

Can I use Module Federation without webpack?

This guide uses the plugin built into webpack 5. If you use another bundler, check its own docs for Module Federation support, and keep the host and every remote on compatible versions.

How do micro frontends affect SEO?

Run-time integration renders content in the browser, so crawlers that don't run JavaScript see less. Server-side composition sends complete HTML instead. For public, search-critical pages, compose on the server or render each fragment on the server first.

Sources

Verified against the sources below on October 29, 2026. Products and docs change often: check the linked sources if something looks different.

  1. Martin Fowler: Micro Frontends (Cam Jackson)
  2. micro-frontends.org: Micro Frontends
  3. webpack: Module Federation
  4. webpack: ModuleFederationPlugin
  5. MDN: CustomEvent() constructor
  6. nginx: ngx_http_ssi_module
  7. Zalando Tailor (archived)
All 30 parts in this series
  1. Part 01Overcoming the Daunting Start: A Strategic Roadmap for New Frontend Developers
  2. Part 02Beyond the Tags: Mastering HTML Architecture for Product-Based Roles
  3. Part 03From Selectors to BEM: CSS Concepts You Must Know for Professional Projects
  4. Part 04Mastering the Primitives: A Builder's Guide to JavaScript Data Types and Functions
  5. Part 05Demystifying Scope and Closure: Key Concepts for Writing Robust JavaScript
  6. Part 06Beyond Frameworks: Practical DOM Manipulation Techniques for High-Performance UIs
  7. Part 07From Prototypes to ES6 Classes: Understanding JavaScript's Object-Oriented Nature
  8. Part 08Architecting Scalable JavaScript: OOP Principles & Design Patterns
  9. Part 09Mastering the Metal: Essential Web APIs & Browser Internals for Frontend Engineers
  10. Part 10Understanding the JavaScript Runtime: Event Loop, Call Stack, and Task Queue Explained
  11. Part 11Mastering Asynchronous Operations with JavaScript Promises: A Builder's Guide
  12. Part 12Modern Async Patterns: Making Asynchronous Code Readable with Async/Await and Generators
  13. Part 13Inside the V8 Engine: A Deep Dive into JavaScript Execution
  14. Part 14Demystifying CORS, HTTP, and Security: A Builder’s Guide
  15. Part 15REST vs. GraphQL: A Frontend Engineer’s Reality Check
  16. Part 16Secure Frontend Auth: The Definitive Guide to JWTs, Cookies, and Storage Strategies
  17. Part 17Why TypeScript Matters: Adding Type Safety to Your JavaScript Projects
  18. Part 18Getting Started with React: Deconstructing JSX and Component Architecture
  19. Part 19React Architecture: Mastering State and Props in Class vs. Functional Components
  20. Part 20Mastering React Hooks: From useState to Building a Production-Ready Custom Hook
  21. Part 21React State Management: Context API vs. Redux & Building a Theme Switcher
  22. Part 22React Architecture: Advanced Navigation and Data Flow Patterns
  23. Part 23Automated Testing in React: Unit Testing with Jest and React Testing Library
  24. Part 24Mastering Chrome DevTools: Debugging Techniques That Save Hours of Development Time
  25. Part 25Automating Code Quality: The Modern Stack with ESLint, Prettier, and Husky
  26. Part 26Demystifying the Build Pipeline: A Deep Dive into Webpack and Babel Configuration
  27. Part 27Improving Performance with Server-Side Rendering: Concepts and Implementation
  28. Part 28From Development to Production: A Builder's Guide to Frontend Deployment Strategies
  29. Part 29Introduction to Micro Frontends: Building Scalable Architectures
  30. Part 30The Frontend Architecture: From Junior Developer to Tech Lead
Written by

Avnish Yadav

AI Automation Engineer & Salesforce Developer

Salesforce developer since June 2018. I build AI agents, n8n workflows and Salesforce integrations, and write up what holds up in real use.

About meLinkedIn

Share
Discussion

Comments

Loading comments...

Add a comment

Comments are reviewed before they appear.