Skip to content

What are Micro-Frontends

Micro Frontends are an architectural pattern that decomposes large, monolithic frontend applications into smaller, independently deployable units. This approach mirrors the principles of microservices but applies them to the frontend layer, enabling teams to manage complex applications by breaking them into isolated, self-contained components. Each micro frontend operates as a separate application with its own codebase, technology stack, and deployment pipeline, yet integrates seamlessly with other units to form a cohesive user experience. This pattern is particularly valuable for large-scale applications where teams need flexibility, scalability, and the ability to evolve different parts of the system independently.


Key Characteristics of Micro Frontends

  1. Independent Deployment
    Each micro frontend can be developed, tested, and deployed separately without affecting other units. This reduces the risk of breaking changes and enables continuous delivery.

  2. Isolated Codebases
    Teams maintain distinct codebases for each micro frontend, preventing tight coupling and allowing for tailored development practices, frameworks, or libraries.

  3. Dynamic Loading
    Micro frontends are often loaded dynamically at runtime, enabling the composition of a complete application by combining multiple units. This is typically achieved via iframes, Web Components, or module federation.


Benefits of Micro Frontends

  • Scalability: Teams can scale development efforts by focusing on specific units, avoiding the bottlenecks of monolithic architectures.
  • Maintainability: Smaller codebases are easier to manage, debug, and update.
  • Technology Flexibility: Different units can use varying frameworks (e.g., React, Vue, Angular) or libraries, accommodating diverse technical requirements.
  • Gradual Adoption: Organizations can transition from monolithic to micro frontend architectures incrementally, minimizing disruption.

Example Integration: Module Federation

# Install shared UI library from a remote registry
npm install @my-org/shared-ui
// Dynamic import of a micro frontend
import { createFederatedComponent } from 'module-federation';

const MyMicroFrontend = createFederatedComponent({
  remoteEntry: 'http://my-mfe-remote.com/remoteEntry.js',
  exposedNames: ['MyComponent'],
});

// Render the integrated micro frontend
ReactDOM.render(<MyMicroFrontend />, document.getElementById('root'));

This example demonstrates how module federation allows micro frontends to share components and communicate across boundaries.


Architecture Diagram

+-------------------+       +-------------------+       +-------------------+
|   User Interface  |<---->|   Micro Frontend A |<---->|   Micro Frontend B |
|   (Container)     |     |   (React-based)    |     |   (Vue-based)      |
+-------------------+     +-------------------+     +-------------------+
           |                         |                         |
           v                         v                         v
+-------------------+       +-------------------+       +-------------------+
| Shared UI Library |<---->|   Shared Services  |<---->|   Shared State    |
|   (npm package)   |     |   (GraphQL API)    |     |   (Redux)         |
+-------------------+     +-------------------+     +-------------------+

The diagram illustrates how micro frontends (A and B) integrate via a shared UI library and services, with the container orchestrating their composition.


Key takeaways

  • Micro frontends split frontend applications into independent, deployable units, enabling scalable and flexible development.
  • They leverage dynamic loading and shared libraries to maintain cohesion across isolated codebases.
  • This pattern supports gradual adoption, technology diversity, and improved team autonomy.
  • Tools like module federation and iframes are critical for enabling cross-unit communication and integration.
  • Success depends on clear boundaries, consistent APIs, and a centralized container for orchestration.