Micro Frontends is a frontend architecture approach to separate the monolith app into several smaller apps to be supported by independent (vertical, product, ...) teams. Micro frontends usually run inside of an app shell is a host system orchestrates micro-frontends.
Each micro-frontend represents a business domain and should meet the requirements below:
Microservices and Micro Frontends aren't fitting all projects.
They are highly depending on the organization structure due to Conway law, therefore you should be able to split your code into domains with clear boundaries.
With the horizontal micro-frontends, teams are dedicated to widgets that may be rendered on the same page.
With this approach, teams are dedicated to domains, such as product detail page, checkout, home page, etc.
Avoid premature optimization, which leads to redundant subdomains decomposition. Postpone the decision to the last possible moment, until you get enough information to make an educated decision.
Always begin with data and metrics, analyze and measure user journey: how many users reach a landing page, how many sign-ins and sign-ups you have, what are next steps in the journey, etc.
There are 3 subdomain types:
There are 3 ways to compose micro-frontends:
In HelloFresh micro-frontends are combined from 3 entities:
Fragment is an isomorphic application served by express server
Particle is an application shared across a platform, such as a header. Particle can be embedded into any host application and all it needs is an element to render to. Particle server returns JSON contains SSR HTML, critical CSS, app state and a link to the script file to mount the application:
{
"html": "<div id=\"react-root\">Test</div>",
"css": "#react-root{color:green}",
"initialState": {
"country": "DE"
},
"script": "https://assets.hellofresh.com/dist/my-particle.hash.js"
}
Tag is a small application triggered asynchronously, like modals.
window.signUpTag({
bindToElement: document.body,
});