← All perspectives

Micro Frontends: Are We Overcomplicating Things?

The benefits, implementation approaches, and organizational trade-offs involved in breaking complex web applications into independently deployed frontends.

The majority of technologists have embraced microservices architecture. The microservices pattern splits a large application into smaller services, with each service taking care of specific functionality.

Microservices architecture is all about backend services, but what about the frontend? It is still one solid piece, right? Micro frontends come in handy in this situation.

What Is It?

The micro frontends pattern is a way of breaking down a large web application into smaller, more manageable pieces. Each piece is a separate frontend application, built with its own technology stack and deployed independently.

As implied by the name, it draws inspiration from the microservices pattern on the backend. But there is a difference. With microservices, we can deploy each service independently. Though micro frontends can also be deployed independently, we need a mechanism to bring all these frontends together to form one application.

How Relevant Is It?

Micro frontends are increasingly popular in modern applications because they break complex applications into smaller, more manageable components. This allows developers to work on different parts of an application in parallel, resulting in faster development cycles and improved scalability.

They can also reduce local complexity by allowing developers to focus on specific areas rather than understand the entire system. This may reduce the risk of introducing bugs or other issues into unrelated parts of the application.

Approaches for Implementing Micro Frontends

As we know, there is a need for a mechanism to bring multiple micro frontends together to form an application. These are some approaches for achieving this.

  1. iframe: Create an iframe for each micro frontend and load its application code inside it. This is simple to implement and provides strong isolation.
  2. Web Components: Use custom HTML elements to encapsulate micro frontend code. This provides isolation and flexibility in styling and layout.
  3. Single-spa: Use the single-spa library to create a single-page application capable of hosting multiple micro frontends.
  4. Server-side composition: Use server-side technology, such as Node.js, to compose the micro frontends into a single application response.

Here is a selection of micro frontend frameworks and tools—though not all of them may strictly be classified as frameworks. This is not an attempt to recommend one. Each option must be carefully examined before deciding which best meets your needs.

Advantages

  1. Improved scalability: Each component can be developed, tested, and deployed independently, making it easier to scale development as needed.
  2. Improved maintainability: Breaking the frontend into smaller components makes it easier to maintain and update each component independently.
  3. Improved team collaboration: Teams can own different parts of the product, divide work more clearly, and integrate changes through defined contracts.
  4. Improved performance opportunities: Smaller components can be optimized separately, although overall application performance still requires system-level attention.

Disadvantages

  1. Increased complexity: Each team is responsible for its codebase and must ensure compatibility with the rest of the system.
  2. Increased cost: Developing and maintaining multiple codebases, pipelines, and hosting units can be expensive.
  3. Increased risk: Multiple independently changing codebases create additional opportunities for bugs and compatibility issues.
  4. Increased coordination: Teams must align on integration, design, security, shared dependencies, and operational practices.

Conclusion

Micro frontends can be an excellent way to divide a large application into smaller, more manageable chunks. They can, however, make the development process more complex. The advantages of micro frontends must be weighed against the complexity they add.

It is definitely complex. If the complexity outweighs the advantages, it may be preferable to stick with a more conventional strategy.