Adopting Micro-Frontends Without Micro-Frontends

Rate this content
Bookmark

Micro-frontends help break up monolithic front-end applications into independently deployable loosely-coupled apps. This architecture helps us scale projects as an organisation scales, however it's also an increase in complexity. How can we leverage this architecture without having to face its upfront cost? In this talk, I'll show some of the risks associated with micro-frontends, and what patterns and libraries we can use to benefit from this architectural style without going full-on micro-frontends.

This talk has been presented at React Advanced Conference 2022, check out the latest edition of this React Conference.

FAQ

A microfrontend is an architectural style where independently deliverable frontend applications are composed into a greater whole, allowing for increased scalability and flexibility in development.

The main benefit of microfrontends is business scalability. They allow organizations to add more streams and teams to a project, potentially doubling output with increased manpower, due to their independent nature.

Common challenges include performance issues due to code duplication and multiple executions, consistency problems from too much independence among components, and potential reliability issues when integrating multiple versions or components.

Microfrontends can impact UI consistency by allowing different versions of a design system across components. Performance can be affected due to the duplication of code and data requests, which may occur when different teams work independently.

A composable app is a construct that allows apps to be embedded and hosted within each other, enabling flexibility in where and how components are displayed without caring about their hosting environment. This concept supports stronger boundaries and better encapsulation in microfrontend architectures.

The LEAN principles for microfrontends involve making them loosely coupled with well-defined interfaces, ensuring they are executed independently, aligning them closely with a business domain, and minimizing dependencies to enhance autonomy and reduce coordination overhead.

It is recommended to keep state management minimal and isolated within each microfrontend to prevent dependencies across different components. Shared state should be limited, and the logic for state manipulation should be confined within the boundaries of the respective microfrontend.

Different versions of a microfrontend can work together by ensuring complete independence between them. This involves avoiding shared states and dependencies, which helps in maintaining functionality even when multiple versions are deployed simultaneously.

Alex Lobera
Alex Lobera
30 min
21 Oct, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Today's Talk explores the adoption of micro frontends without actually implementing them. The main benefits of micro frontends are business scalability and the ability to independently deploy and compose frontend applications. The process of breaking up a monolith into smaller parts can be done using LEAN principles and composable apps. State management and data sharing in micro frontends are complex topics that require careful consideration to avoid coupling and maintain loose coupling.

1. Introduction to Micro Frontends

Short description:

Today I'm going to talk about adopting micro frontends without micro frontends. What is a microfrontend? It's an architectural style where independently deliverable frontend applications are composed into a greater whole. The main benefit of microfrontends is business scalability. However, there are cons such as performance and consistency issues.

Today I'm going to talk about adopting micro frontends without micro frontends. Ruben, the previous speaker, he gave a great talk and I was just there looking at what he was saying. I was like, wow, he actually explained everything. So now I'm going to try to convince you how to maybe not go towards the end of that path.

Who am I? Alex. I was introduced. I currently work for Miro. If you don't know Miro, it's a very complex frontend. Very challenging. It's an infinite realtime collaboration ward. Really challenging. If you want to join the challenge, you can join the company. And today, you know, Ruben didn't give you the definition, so here I am. I'm going to give it to you. What is a microfrontend? And this is the, I would say the canonical definition you will find in any blog post and conference talk which was written a few years ago and basically says that it's an architectural style where independently deliverable frontend applications are composed into a greater whole.

So what's the point of microfrontends? What do you get? The main benefit is business scalability. And it means that you can add more people to your project, and let's say you double the number of people who work there, then you double the outcome. And you do that because they are independent things, right? You can add a new stream, a new value stream, and so on, and so that's why it's scalable. Not to confuse with, like, platform or where your software is running, because your frontend application will run at some point, unless you don't have JavaScript, on a browser, and you're not going to be able to scale that thread. So what are the cons? First is performance. You know, you can effect performance in two different ways. One is your application. You're making things very independent, and so you might or might not duplicate certain code. You know, the classic thing. You download the same framework twice. You also need to execute things, some things you can execute twice, and you also maybe request data twice, but also your teams, maybe because you are making things, if you're really focused on making things very independent, maybe they duplicate work, they create CI pipelines for very different repos, and so on. You can also effect consistency for the same reason, just making things independent. Now, if you read any articles, most talks about micro-frontends, they say don't share any state. You shouldn't do that. The reason is, because you want to make things independent, but if you don't share that state, you keep, if you change the language in one micro-frontend, I guess you want to change the language in the other one, how do you know? How do you fix that? Same with design.

2. Reliability and Micro Frontends

Short description:

You can create a design system with different versions. Reliability is crucial for code execution. Let's use Twitter as an example. Breaking it into micro-frontends, we have a feed and a reply micro-frontend. Different versions can be deployed, but if they are independent, they should work.

You can create a design system, but you can also have different versions of your design system. And then reliability. And by reliability I mean, when you execute some code, it basically should not fail, right? Once the code, it should produce the expected outcome. Those are, you know, you have ways to work around that and to improve those things and mitigate quite a lot of those things. Performance and consistency. But it's not the case with reliability.

Let me give you an example. I'm going to use Twitter as an example here. Let's say we want to break up Twitter into micro-frontends. And so, we have this page contains, this is the home page. It's a feed page and this is, we'll create a feed micro-frontend. When you click on that button, it shows a model and we could create another micro-frontend for that. It's a different team, engaging team, whatever. It's micro-frontend, we'll call it reply micro-frontend.

What's going to happen is, at some point in time, we have these two versions, everything is working. So, the user goes to Twitter, then the user gets an HTML that says, oh, you need to download this JavaScript for the feed. And so, you, that's fine, it works. It's, it's displayed on the browser. But then on the background, version two of that micro-frontend is deployed. You can test that, you can also test that, ensure that journey where the user is on a feed and replying to a tweet, works. You can run some integration tests, works, release. Then a new version is deployed. You can do the same. You can test, release, and so on. This point in time, the user didn't, didn't reply, so didn't execute that action. At the point in time later, the user wants to reply, some tweet, and then it gets the version three of this microfrontend. So the question is, will it work? We never tested that, right? You could test that, but imagine it grows exponentially. The more releases you have and the more microfrontend, it will be like, enormous amount of work, so you probably don't test. Will it work? Well, the answer is, if they are completely independent, they should work. Right? So that's fine.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
This talk discusses the usage of Microfrontends in Remix and introduces the Tiny Frontend library. Kazoo, a used car buying platform, follows a domain-driven design approach and encountered issues with granular slicing. Tiny Frontend aims to solve the slicing problem and promotes type safety and compatibility of shared dependencies. The speaker demonstrates how Tiny Frontend works with server-side rendering and how Remix can consume and update components without redeploying the app. The talk also explores the usage of micro frontends and the future support for Webpack Module Federation in Remix.
Monolith to Micro-Frontends
React Advanced Conference 2022React Advanced Conference 2022
22 min
Monolith to Micro-Frontends
Top Content
Microfrontends are considered as a solution to the problems of exponential growth, code duplication, and unclear ownership in older applications. Transitioning from a monolith to microfrontends involves decoupling the system and exploring options like a modular monolith. Microfrontends enable independent deployments and runtime composition, but there is a discussion about the alternative of keeping an integrated application composed at runtime. Choosing a composition model and a router are crucial decisions in the technical plan. The Strangler pattern and the reverse Strangler pattern are used to gradually replace parts of the monolith with the new application.
Micro-Frontends With React & Vite Module Federation
React Advanced Conference 2023React Advanced Conference 2023
20 min
Micro-Frontends With React & Vite Module Federation
Top Content
Watch video: Micro-Frontends With React & Vite Module Federation
Microfrontends is an architecture used by big companies to split monolithic frontend applications into manageable parts. Maintaining a consistent look and feel across different microfrontends is a challenge. Sharing styles can be done through Vanilla CSS, CSS modules, or CSS in JS. JavaScript variables can be used in styles, but readability and runtime overhead are considerations. Sharing state in microfrontends can be achieved through custom events, broadcast channels, shared state managers, or custom PubSub implementations. Module federation with Vite allows for client composition and sharing dependencies. Configuration is similar to Webpack, and future work includes working on the QUIC framework.
Federated Microfrontends at Scale
React Summit 2023React Summit 2023
31 min
Federated Microfrontends at Scale
Top Content
Watch video: Federated Microfrontends at Scale
This Talk discusses the transition from a PHP monolith to a federated micro-frontend setup at Personio. They implemented orchestration and federation using Next.js as a module host and router. The use of federated modules and the integration library allowed for a single runtime while building and deploying independently. The Talk also highlights the importance of early adopters and the challenges of building an internal open source system.
“Microfrontends” for Mobile in React Native
React Advanced Conference 2023React Advanced Conference 2023
24 min
“Microfrontends” for Mobile in React Native
Top Content
Watch video: “Microfrontends” for Mobile in React Native
Micro frontends are an architectural style where independent deliverable frontend applications compose a greater application. They allow for independent development and deployment, breaking down teams into feature verticals. React Native's architecture enables updating the JavaScript layer without going through the app store. Code Push can be used to deploy separate JavaScript bundles for each micro frontend. However, there are challenges with managing native code and dependencies in a micro frontend ecosystem for mobile apps.
Sharing is Caring: (How) Should Micro Frontends Share State?
React Summit 2022React Summit 2022
23 min
Sharing is Caring: (How) Should Micro Frontends Share State?
Top Content
Micro-frontends allow development teams to work autonomously and with less friction and limitations. Organizing teams around business concerns, in alignment with subdomains, rather than technical concerns, can lead to software that is split nicely and user stories falling under the responsibility of a single team. Having a logical backup or reference point is important for implementing microfrontends without breaking their isolation. Microfrontends can communicate with each other using the window object and custom events. Microfrontends should be kept isolated while maintaining communication through various approaches.

Workshops on related topic

Micro Frontends with Module Federation and React
JSNation Live 2021JSNation Live 2021
113 min
Micro Frontends with Module Federation and React
Workshop
Alex Lobera
Alex Lobera
Did you ever work in a monolithic Next.js app? I did and scaling a large React app so that many teams can work simultaneously is not easy. With micro frontends you can break up a frontend monolith into smaller pieces so that each team can build and deploy independently. In this workshop you'll learn how to build large React apps that scale using micro frontends.
Micro-Frontends with Module Federation and Angular
JSNation Live 2021JSNation Live 2021
113 min
Micro-Frontends with Module Federation and Angular
Workshop
Manfred Steyer
Manfred Steyer
Ever more companies are choosing Micro-Frontends. However, they are anything but easy to implement. Fortunately, Module Federation introduced with webpack 5 has initiated a crucial change of direction.
In this interactive workshop, you will learn from Manfred Steyer -- Angular GDE and Trusted Collaborator in the Angular team -- how to plan and implement Micro-Frontend architectures with Angular and the brand new webpack Module Federation. We talk about sharing libraries and advanced concepts like dealing with version mismatches, dynamic Module Federation, and integration into monorepos.
After the individual exercises, you will have a case study you can use as a template for your projects. This workshop helps you evaluate the individual options for your projects.
Prerequisites:You should have some experience with Angular.