Skip to the content.
mfe

Micro Frontend

Micro Frontends (MFE) is an architectural style that brings the principles of microservices to the world of frontend development. In this approach, a large frontend application is broken down into smaller, more manageable, independent units or micro-apps, each responsible for a specific feature or functionality.

Just like microservices, these frontend modules can be developed, deployed, and maintained independently, while being integrated into a cohesive application. The goal of MFE is to decentralize the frontend monolith and allow for a more scalable, flexible, and maintainable application.

Key Concepts of Micro Frontends

How Micro Frontends Work

Micro Frontends work by breaking down the user interface (UI) into isolated “micro-apps” that are responsible for different features or sections of the application. Each micro frontend is developed and deployed independently, but they are integrated into a container or shell application, which is responsible for assembling and rendering the complete UI.

Key Steps:

  1. Domain Separation: Each micro frontend is responsible for a specific domain, such as the user profile, shopping cart, or checkout.
  2. Integration: Micro Frontends are integrated into a larger application shell that combines the individual micro-apps into a cohesive user interface.
  3. Routing and Communication: Each micro frontend handles its own internal routing, and cross-component communication can be achieved via shared events, state, or APIs.

Benefits of Micro Frontends

  1. Scalability: Teams can work on different parts of the application independently, allowing the development of large applications by smaller, autonomous teams.
  2. Flexibility: Teams can choose different technologies for different micro frontends, making it easier to experiment with new tools or migrate between technologies.
  3. Faster Development: By decoupling the frontend, development cycles are faster, and features can be rolled out more quickly.
  4. Improved Maintainability: Smaller, self-contained components are easier to maintain and update without affecting the entire application.

Challenges of Micro Frontends

  1. Increased Complexity: Micro Frontends introduce complexity in terms of integration, routing, and communication between modules, especially when teams use different technologies.
  2. Performance Overhead: If not managed properly, integrating multiple micro frontends can lead to performance issues, particularly if multiple frameworks or libraries are used.
  3. UI Consistency: Maintaining a consistent user interface and user experience across multiple micro frontends can be challenging, especially when teams work with different design systems or UI frameworks.
  4. Cross-Team Coordination: Although teams can work independently, coordination is still required to ensure that micro frontends integrate seamlessly and maintain consistency.

Approaches for Integrating Micro Frontends

Micro Frontends can be integrated into a single application using a variety of techniques. Here are some common approaches:

1. Web Components

2. Iframe Embedding

3. JavaScript Bundling

4. Single SPA

Example of Micro Frontends in Action

Imagine an e-commerce platform with multiple sections, each developed by a different team:

These micro frontends are integrated into a larger container application that orchestrates their display and functionality, while allowing each team to independently deploy and update their section without affecting the others.

When to Use Micro Frontends

Micro Frontends are particularly useful in the following scenarios:

References