Skip to Content

What Is a Micro Frontend?

What Is a Micro Frontend?

Most developers have already heard about microservice architecture, but micro frontend is a much lesser-known term. As the name suggests, micro frontend is similar in concept to microservices. It attempts to solve many of the same issues that monolithic applications present. They’re too big, hard to work with, and difficult to make changes to. Onboarding new people to work on them can be a pain. Also, if multiple teams of people are working on different parts of the application, they’ll need to coordinate all their changes with each other.

Microservices help you split the backend into more independent services. The same approach can be used to split single page applications (SPAs) into smaller apps, with the additional need for an “orchestrator” that can put different parts back together so that the user is still experiencing SPA behavior.

What Are the Alternatives to a Micro-Frontend Architecture?

Of course, there are other ways to deal with some of the undesired aspects of huge applications, like separating part of the code into its own npm package. That can solve part of the problem, like the repo being too big. For example, in Angular, you can also separate code into a module that can be lazy loaded. This can allow for vertical splitting of the application to some extent. But, it also has its disadvantages, like having to build the top-level project when one of the dependencies is updated. Also, the developer experience isn’t that great. When using any sort of framework, it’s a good idea to upgrade everything to the same version, but it’s a huge undertaking that no one is excited to do. You also have the option to join multiple apps together via iframe. It makes them independent, but I’d say maybe too independent as inter-app communication is a problem and so is sharing code, styles, etc. 

Micro Frontends to the Rescue?

Micro frontends are a combination of these two approaches. Each micro frontend is a separate application that is in comparison to the SPA. It isn’t compiled to an index.html with linked script and style files but to a JavaScript module. Instead of an iframe in the “main” app, code defines that when the URL is matching some pattern, the module is then lazy loaded and placed in a specific spot. Thanks to this we can have multiple apps on the same page that can be interconnected with each other.

As a result, micro frontends don’t need to handle app layout and basic CSS rules that can only be handled in the main app. Equally beneficial is the fact that if I have multiple micro frontends using the same version of React, then I can have them share the React module. It doesn’t have to be downloaded separately for each micro frontend. Having different versions of a JS module is also not a problem.

The main worry with micro frontends is to make sure that their styles don’t overflow to other parts of the application. Fortunately, most commonly used UI frameworks have tools to handle that with ease.

Tooling for Micro-Frontend Architectures

Writing your own code to load micro-frontend applications would be quite a task. Fortunately, there are multiple frameworks that handle orchestration and offer tooling to convert apps written in the most-popular frameworks to the micro-frontend format.

At Pure, we chose single-spa. The main benefits we’ve found are that it’s easy to understand, offers wide support for JS frameworks, and has detailed documentation. In addition, single-spa offers multiple types of micro frontends, each suited for slightly different jobs.

At the moment, we’re only using “Application” type because it’s the easiest to use for moves from SPA to micro frontends. Other types also require more detailed micro-frontend architecture. Also, “Application” is recommended as the default by the single-spa authors.

Application

Parcel

Utility

Routing

One or more routes

No

No

API

Declarative API

Imperative API

Exports interface

UI

Renders UI

Renders UI

Can render UI

Life Cycle

single-spa

Own

External module without life cycle

When to Use

Basic building block

Component to be used in different frameworks

Sharing of logic

Slide

Building Micro Frontends Using the Single-SPA Framework

At the moment, we’re using single-spa with one of our bigger apps that currently contains about five micro frontends. Sometimes, different teams are working on these micro frontends than the main app development teams. Fortunately, in the last six months since switching to micro frontends, we’ve had zero issues reported. We’re also pretty happy that the main app isn’t as bloated as it was in the past and can be upgraded more easily. In addition, we don’t worry about side effects when adding new functionality since it’s usually done with a micro frontend. In the near future, we’d like to split frontends of other large apps that we‘re developing at Pure as the benefits are likely to be pretty significant for them as well. We recommend giving micro frontends a try if you’re facing the same issues we were.

11/2024
APIS IT Delivers Government Cloud in Croatia
Discover how Pure Storage helped APIS IT build the backbone of Croatia’s government cloud.
Case Study
3 pages

Browse key resources and events

CYBER RESILIENCE
The Blueprint for Cyber Resilience Success

Explore how IT and security teams can seamlessly collaborate to minimize cyber vulnerabilities and avoid attacks.

Show Me How
WEBINAR
Redefining the Future of Storage Platforms
Dec 4, 2024

Join us to discover how Gartner's new platform direction is shaking up the traditional storage industry and putting it on notice.

Register Now
WEBINAR
Pure Storage and Rubrik: A Multi-layered Approach to Cyber Resilience
Dec 5, 2024

Join us as we dive into our three-layered, cyber resilience solution that secures data and minimizes downtime.

Register Now
INDUSTRY EVENT
Future-Proof Your Hybrid Cloud Infrastructure at AWS re:Invent 2024

Meet Pure Storage at AWS re:Invent and prepare your hybrid cloud infrastructure for what’s new and what’s next.

Book a Meeting
CONTACT US
Meet with an Expert

Let’s talk. Book a 1:1 meeting with one of our experts to discuss your specific needs.

Questions, Comments?

Have a question or comment about Pure products or certifications?  We’re here to help.

Schedule a Demo

Schedule a live demo and see for yourself how Pure can help transform your data into powerful outcomes. 

Call Sales: 800-976-6494

Mediapr@purestorage.com

 

Pure Storage, Inc.

2555 Augustine Dr.

Santa Clara, CA 95054

800-379-7873 (general info)

info@purestorage.com

CLOSE
Your Browser Is No Longer Supported!

Older browsers often represent security risks. In order to deliver the best possible experience when using our site, please update to any of these latest browsers.