Free 20-minute strategy call with a senior engineer: AI, payments, eLearning or custom software
Engineering

A Complete Guide to React Micro Frontends

A Complete Guide to React Micro Frontends

In short

A complete guide to micro frontends with React: what they are, benefits and limits, Module Federation architecture and how to build React micro frontends.

As a React application grows, a single front-end codebase shared by many teams becomes slow to build, risky to release and hard to change. Micro frontends split that front end into smaller applications that different teams can build, test and deploy independently, then compose into one experience for the user. This guide explains what React micro frontends are, when they are worth it, how to build them with Module Federation, and the mistakes to avoid.

What are micro frontends?

Micro frontends apply the idea of microservices to the user interface. Instead of one large React app, you have:

  • a host (also called the shell or container) that owns the layout, routing and shared services such as authentication, and
  • several remotes, each owning a business area such as checkout, account or search, built and deployed by its own team.

The browser loads the host first, then loads each remote’s code when it is needed. To the user it looks and behaves like a single application.

When should you use React micro frontends?

Micro frontends solve organisational problems more than technical ones. They pay off when:

  • several teams work on the same front end and block each other’s releases,
  • different parts of the product need independent release cycles,
  • you are migrating gradually from a legacy front end (AngularJS, jQuery or an old React version) and want to replace it screen by screen,
  • the application is large enough that build and test times hurt productivity.

They are usually not worth it for a single team, a small product or an MVP. A well-structured monorepo with clear module boundaries is simpler and faster in those cases.

Benefits and trade-offs

BenefitsTrade-offs
Independent deployments per teamMore infrastructure and CI/CD pipelines
Smaller, faster codebasesRisk of duplicated dependencies and larger downloads
Gradual migration from legacy front endsShared state and communication need careful design
Teams can upgrade at their own paceConsistent UX requires a shared design system
Faults can be isolated to one areaEnd-to-end testing across apps is harder

Ways to compose micro frontends

  1. Build-time composition: remotes are published as npm packages and installed in the host. Simple, but every change requires redeploying the host, so teams lose independence.
  2. Run-time composition with Module Federation: the host loads remote code over the network at run time. This is the most popular approach for React today.
  3. Framework orchestration (single-spa): a router mounts and unmounts applications, which can even use different frameworks.
  4. Iframes: strong isolation, but poor for SEO, accessibility, shared navigation and performance. Best kept for embedding third-party tools.

React micro frontend architecture with Module Federation

Module Federation, introduced in webpack 5 and now also available for Rspack and Vite, lets one build expose modules that another build imports at run time. Below is a minimal setup with one host and one remote.

Free resource

Upgrade and patching checklist

Want this applied to your project? Our engineers will send it with notes for your stack.

Get it free

1. The remote app exposes a component

webpack.config.js in the checkout app:

const { ModuleFederationPlugin } = require('webpack').container;
const deps = require('./package.json').dependencies;

module.exports = {
  output: { publicPath: 'auto' },
  plugins: [
    new ModuleFederationPlugin({
      name: 'checkout',
      filename: 'remoteEntry.js',
      exposes: {
        './CheckoutPage': './src/CheckoutPage',
      },
      shared: {
        react: { singleton: true, requiredVersion: deps.react },
        'react-dom': { singleton: true, requiredVersion: deps['react-dom'] },
      },
    }),
  ],
};

2. The host app consumes it

webpack.config.js in the shell app:

new ModuleFederationPlugin({
  name: 'shell',
  remotes: {
    checkout: 'checkout@https://checkout.example.com/remoteEntry.js',
  },
  shared: {
    react: { singleton: true, requiredVersion: deps.react },
    'react-dom': { singleton: true, requiredVersion: deps['react-dom'] },
  },
});

3. Lazy-load the remote in React

import React, { Suspense, lazy } from 'react';
import { ErrorBoundary } from 'react-error-boundary';

const CheckoutPage = lazy(() => import('checkout/CheckoutPage'));

export default function CheckoutRoute() {
  return (
    <ErrorBoundary fallback={<p>Checkout is temporarily unavailable.</p>}>
      <Suspense fallback={<p>Loading checkout…</p>}>
        <CheckoutPage />
      </Suspense>
    </ErrorBoundary>
  );
}

The error boundary matters: if the checkout team deploys a broken build or its server is down, the rest of the application keeps working.

4. Bootstrap asynchronously

Module Federation needs shared dependencies to be negotiated before React starts. Put your app start-up in bootstrap.js and import it dynamically from the entry file:

// index.js
import('./bootstrap');

Sharing dependencies safely

  • Mark React and React DOM as singletons. Two copies of React on one page break hooks and context.
  • Keep shared library versions aligned across teams, and use requiredVersion so mismatches show up as warnings rather than silent bugs.
  • Share only what must be shared (React, the design system, the router). Sharing too much couples the apps again.

Communication between micro frontends

Keep remotes loosely coupled:

  • Props and callbacks from the host for simple cases.
  • Browser custom events (window.dispatchEvent(new CustomEvent('cart:updated', { detail }))) for cross-app notifications.
  • The URL for state that should survive a refresh, such as filters and selected items.
  • A small shared service exposed by the host for authentication and user details.

Avoid a single global store shared by every app. It recreates the coupling micro frontends are meant to remove.

Routing

The host owns top-level routes (/checkout/*, /account/*) and hands everything under that path to the matching remote, which manages its own nested routes. With React Router this means each remote renders its own <Routes> inside the route the host gives it.

Styling and design consistency

  • Publish a shared design system (tokens, components and fonts) that every remote uses.
  • Prevent style clashes with CSS Modules, CSS-in-JS with unique prefixes, or a prefix per remote.
  • Agree on accessibility standards so keyboard navigation and focus behave the same everywhere.

Performance tips

  • Lazy-load remotes per route so users only download what they use.
  • Avoid shipping multiple versions of large libraries; check bundles regularly.
  • Cache remoteEntry.js briefly and versioned chunks for a long time.
  • Measure Core Web Vitals for the composed application, not just each remote in isolation.

Testing and deployment

  • Each remote has its own unit tests and pipeline and deploys independently.
  • Run contract tests for anything a remote exposes, so the host is not broken by a change in props.
  • Keep a small suite of end-to-end tests (for example with Playwright) against the composed app in staging.
  • Make remote URLs configurable per environment so you can roll back one remote without redeploying the host.

Common mistakes to avoid

  1. Splitting by technical layer (header app, footer app) instead of by business capability.
  2. Creating micro frontends for a single team that does not need independent deployments.
  3. Sharing too many libraries, or none at all, which leads to tight coupling or duplicate downloads.
  4. Forgetting error boundaries and loading states for remotes.
  5. Letting each team invent its own UI patterns, which produces an inconsistent product.

Frequently asked questions

What is a micro frontend in React? A micro frontend is an independently built and deployed part of a React application, such as checkout or account settings, that a host application loads and composes at run time.

Is Module Federation the best way to build React micro frontends? For most React teams, yes. It supports run-time loading, shared dependencies and independent deployments. single-spa is a good alternative when you need to mix frameworks.

Can micro frontends use different React versions? It is possible but not recommended. Running different React versions on one page increases download size and complexity, so most teams keep React as a shared singleton.

Do micro frontends hurt SEO? Not if the main content is server-rendered or rendered quickly, and you avoid iframes. Frameworks such as Next.js can be combined with Module Federation for server-rendered micro frontends.

When should I not use micro frontends? When one team owns the whole front end, the product is small, or you do not need independent releases. A modular monolith is simpler in those cases.

Planning a micro frontend architecture?

Vibidsoft helps teams split large React applications into maintainable micro frontends, or migrate legacy front ends to React step by step. See our React and Next.js development services and frontend development, or contact us for an architecture review.

Vibidsoft Engineering Team

Senior engineers who have shipped 450+ projects since 2014 across AI, payments, eCommerce, eLearning and custom software. Every guide is written and reviewed by the people who do the work.

Follow us on LinkedIn · About Vibidsoft

Next step

Talk to an engineer about Modernize & Rescue

Fixed-price upgrades for ageing PHP, Drupal, Magento or hybrid apps, with security patching and a care plan. from $5,000.

  • A 20-minute call with a senior engineer, not a salesperson
  • A written next-step plan within one business day
  • NDA on request
Book a call WhatsApp