SlideShare a Scribd company logo
Micro Frontends
You Keep Using That Word, I
Don’t Think It Means What You
Think It Means.
Shem Magnezi | @shemag8
@shemag8
Once upon a time in
WeWork, community managers
needed a managing tool
@shemag8
@shemag8
@shemag8
Things started to get bigger
@shemag8
@shemag8
2017
1 Team
~5 Eng
1 PM
2019
~10 Teams
~50 Eng
>5 PMs
@shemag8
At this point we have
2 options
@shemag8
Plan
ahead
Business
as usual
@shemag8
@shemag8
Shem Magnezi
Staff Engineer
@shemag8
@shemag8
This is a common pattern
@shemag8
Let’s frame the problem
@shemag8
#1: High cohesion
@shemag8
#2: Loose coupling
@shemag8
#3: Limited blast radius
@shemag8
#4: Data segregation
@shemag8
#5: Presenting an API
@shemag8
Isn’t it familiar?
@shemag8
Why microservices for front-
end isn’t that simple?
@shemag8
#1: User should feel it’s a single app
@shemag8
#2: Keep bundle size small
@shemag8
#3: Responsive as fast as possible
@shemag8
#4: No standard API
@shemag8
But the concept is somehow
similar
@shemag8
Framework (AKA stiching layer)
Module 1 Module 2 Module 3 Module 4
Core library
Communication
between
modules
Update
modules
Notifications
User’s
session
Shared
components
@shemag8
Your mileage may vary
@shemag8
Questions you want to ask
● Do all teams work on same framework (and
version)?
● Single deploy or independent deploy for each
module?
● Modules should be shared between apps?
● Modules should be loaded dynamically?
● Do we need to support SSR?
● ...
@shemag8
@shemag8
Here we go:
Same framework:
1. NPM Modules
2. Lerna
Multiple frameworks:
3. Web Components
4. App per route
5. IFrames
6. Single SPA
@shemag8
NPM
module1
NPM
module2
App
NPM Modules
@shemag8
/package.json:
"dependencies": {
"@wework/moduleA": "0.1.6",
"@wework/moduleB": "1.1.6",
...
}
index.js:
import ModuleAComp from
'wework/modeulA'
<ModuleAComp />
moduleA/index.js:
export default ModuleAComp;
moduleA/package.json:
{
"name": "@wework/moduleA",
"author": ...
"main": ...,
"version": "0.1.6",
"peerDependencies": {
...
}
}
@shemag8
NPM
module1
NPM
module2
App
NPM Modules
● Develop each module
in its own separate
independent repo
● The main app is just
wiring NPM modules
packaged together
@shemag8
Package 1 Package 2
Main Package
Lerna
@shemag8
> lerna init
lerna-repo/
packages/
package-1/
package.json
package-2/
package.json
package.json
lerna.json
@shemag8
Package 1 Package 2
Main Package
Lerna
● Managing versioning
● Managing
dependencies
● Used by Babel, React,
Angular, Jest
@shemag8
<Module 1> <Module 2>
Plain old HTML (and JS)
Web Components
@shemag8
moduleA/fragments.js:
class ModuleA extends HTMLElement {
constructor() {
super();
this.innerHTML = `<button
type="button">Text</button>`;
}
}
window.customElements.define('moduleA',
ModuleA);
page.js:
$app.innerHTML = `
<moduleA id="buy"></moduleA>
`;
index.html:
<!doctype html>
<html lang="en">
<head>
</head>
<body>
<main id="app"></main>
<script src="./page.js" async></script>
<script src="./moduleA/fragments.js"
async></script>
</body>
</html>
@shemag8
<Module 1>
● Technology Agnostic
● The DOM is the API
● Native support by
most browsers
● No shared state
<Module 2>
Plain old HTML (and JS)
Web Components
@shemag8
/package1 /package2
API Proxy
App per route
@shemag8
server {
# Decide which HTML fragment to
insert based on the URL
location /browse {
set $PAGE 'browse';
}
location /order {
set $PAGE 'order';
}
location /profile {
set $PAGE 'profile'
}
error_page 404 /index.html;
}
<html lang="en" dir="ltr">
<body>
<h1>Common code</h1>
<!--# include file="$PAGE.html" -->
</body>
</html>
@shemag8
/package1
● Support SSR
● Each package has its
own dedicated page
● Can be divided into
fragments and not
full pages /package2
API Proxy
App per route
@shemag8
Frame 1 Frame 2
Main app
IFrames
@shemag8
<html>
<body>
<iframe id="micro-frontend-container"></iframe>
<script type="text/javascript">
const microFrontendsByRoute = {
'/': 'https://browse.example.com/index.html',
'/order-food': 'https://order.example.com/index.html',
'/user-profile': 'https://profile.example.com/index.html',
};
const iframe = document.getElementById('micro-frontend-container');
iframe.src = microFrontendsByRoute[window.location.pathname];
</script>
</body>
</html>
@shemag8
Frame 1
● No heavy lifting or
dependency
complexity
● Complete separation
● Very nostalgic
● Used by Spotify Frame 2
Main app
IFrames
@shemag8
App 1 App 2
single-spa-config
Single SPA
@shemag8
index.html:
<body>
<script
src="config.js"></script>
</body>
config.js:
import * as singleSpa from 'single-spa';
const loadingFunction = () =>
import('./app1/app1.js');
const activityFunction = location =>
location.pathname.startsWith('/app1');
singleSpa.registerApplication('app1',
loadingFunction, activityFunction);
singleSpa.start();
app1/app.js:
export function bootstrap(props) {
return Promise.resolve().then(() => {
domEl =
document.createElement('div');
domEl.id = 'app1';
document.body.appendChild(domEl);
});
}
export function mount(props) {
return Promise.resolve().then(() => {
domEl.textContent = 'App 1 is
mounted!'
});
}
export function unmount(props) {
...
@shemag8
App 1
● Use multiple
frameworks on the
same page
● No refresh
● Lazy load
App 2
single-spa-config
Single SPA
@shemag8
Wait, what about
communication?
@shemag8
Option #1:
State management
@shemag8
Option #2:
Event based communication
dispatchEvent EventEmitter
@shemag8
@shemag8
@shemag8
What's in it for me?
@shemag8
Breaking the monolith is inevitable
@shemag8
You have to plan ahead to scale fast
@shemag8
There are plenty of options out
there
@shemag8
It’s all about your team and
product
@shemag8
@shemag8
Thanks
You can find me at
blog.shem.dev
@shemag8
Resources
● Lerna- http://bit.ly/2VAelIc
● Web Components- http://bit.ly/2PyN5V1
● Single SPA- http://bit.ly/2DB1f3a
● Miro FE (by Martin Fowler)- http://bit.ly/2knpmMJ
● IFrames- http://bit.ly/2vse4IE
● Exploring micro-frontends- http://bit.ly/2ZIc8cX
● Micro Frontends - Think Smaller, Avoid the
Monolith Love the Backend- http://bit.ly/2DzB39e

More Related Content

PPTX
Micro frontends
PPTX
[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...
PPTX
Performance optimization of vue.js apps with modern js
PDF
Refactoring to a Single Page Application
PPTX
PWA basics for developers
PDF
Blazor web apps
PPT
MTaulty_DevWeek_Silverlight
PPTX
Vue Storefront MUG
Micro frontends
[DevDay2019] Micro Frontends Architecture - By Thang Pham, Senior Software En...
Performance optimization of vue.js apps with modern js
Refactoring to a Single Page Application
PWA basics for developers
Blazor web apps
MTaulty_DevWeek_Silverlight
Vue Storefront MUG

What's hot (19)

PPTX
Imagine recap-devhub
PDF
Magento 2 Development for PHP Developers
PDF
Fitur Terbaru Flutter di Tahun 2021 - Widyarso Joko Purnomo
PPTX
Single Page Application (SPA) using AngularJS
PPTX
Sony lazuardi native mobile app with javascript
PDF
Magento 2 Design Patterns
PDF
The Ultimate Getting Started with Angular Workshop - Devoxx UK 2017
DOCX
Portfolio
PPTX
How to build your own Hybrid JS Interface with Android?
PPTX
Goodbye JavaScript Hello Blazor
PPTX
Introduction to Django
PDF
Magento 2 Modules are Easy!
PDF
How To Install Magento 2 (updated for the latest version)
PDF
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
PDF
Angular js - 10 reasons to choose angularjs
PPTX
Full stack web development
PDF
SEO methods in Single Page Applications
PDF
Web Development Presentation
PPTX
Blazor - An Introduction
Imagine recap-devhub
Magento 2 Development for PHP Developers
Fitur Terbaru Flutter di Tahun 2021 - Widyarso Joko Purnomo
Single Page Application (SPA) using AngularJS
Sony lazuardi native mobile app with javascript
Magento 2 Design Patterns
The Ultimate Getting Started with Angular Workshop - Devoxx UK 2017
Portfolio
How to build your own Hybrid JS Interface with Android?
Goodbye JavaScript Hello Blazor
Introduction to Django
Magento 2 Modules are Easy!
How To Install Magento 2 (updated for the latest version)
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Angular js - 10 reasons to choose angularjs
Full stack web development
SEO methods in Single Page Applications
Web Development Presentation
Blazor - An Introduction
Ad

Similar to “Micro Frontends”- You Keep Using That Word, I Don’t Think It Means What You Think It Means (20)

PPTX
“Micro Frontends”- You Keep Using That Word, I Don’t Think It Means What You ...
PPTX
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
PPTX
How NOT to get lost in the current JavaScript landscape
PDF
Headless Magento - Meet Magento Poland 2017
PDF
Polymer & PWA: Understanding the “why”
PDF
The state of navigator.register protocolhandler
PDF
Creando microservicios con Java y Microprofile - Nicaragua JUG
PDF
Neoito — How modern browsers work
PDF
C# and Dot Net Framework 1st & 2nd Unit.pdf
PPT
Ajax
PPTX
Building and managing applications fast for IBM i
PDF
Polymer is production ready, how about you?
PDF
Codemotion Rome 2016 - Polymer
PDF
Getting Started with Playwright: A Beginner-Friendly Introduction & Setup Guide
PDF
Testing with Codeception
PDF
What's New and Newer in Apache httpd-24
PDF
Open Social Summit Korea
PPT
Thadomal IEEE-HTML5-Workshop
PDF
JSFest 2019: Technology agnostic microservices at SPA frontend
PDF
Automating with operators - FossAsia Summit 2019
“Micro Frontends”- You Keep Using That Word, I Don’t Think It Means What You ...
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
How NOT to get lost in the current JavaScript landscape
Headless Magento - Meet Magento Poland 2017
Polymer & PWA: Understanding the “why”
The state of navigator.register protocolhandler
Creando microservicios con Java y Microprofile - Nicaragua JUG
Neoito — How modern browsers work
C# and Dot Net Framework 1st & 2nd Unit.pdf
Ajax
Building and managing applications fast for IBM i
Polymer is production ready, how about you?
Codemotion Rome 2016 - Polymer
Getting Started with Playwright: A Beginner-Friendly Introduction & Setup Guide
Testing with Codeception
What's New and Newer in Apache httpd-24
Open Social Summit Korea
Thadomal IEEE-HTML5-Workshop
JSFest 2019: Technology agnostic microservices at SPA frontend
Automating with operators - FossAsia Summit 2019
Ad

More from Shem Magnezi (16)

PDF
The Journey of a Pixel in a React Application
PDF
AI funnel optimization talk - Shem Magnezi
PDF
The Future of Work(ers)
PPTX
Good rules for bad apps
PPTX
Iterating on your idea
PPTX
The Redux State of the Art
PPTX
Startup hackers toolbox
PDF
Fuck you startup world
PDF
The Future of Work
PPTX
Android Developer Toolbox 2017
PPTX
Good rules for bad apps
PDF
Building android apps with kotlin
PDF
Andriod dev toolbox part 2
PPTX
Android dev toolbox
PDF
Know what (not) to build
PDF
Android ui tips & tricks
The Journey of a Pixel in a React Application
AI funnel optimization talk - Shem Magnezi
The Future of Work(ers)
Good rules for bad apps
Iterating on your idea
The Redux State of the Art
Startup hackers toolbox
Fuck you startup world
The Future of Work
Android Developer Toolbox 2017
Good rules for bad apps
Building android apps with kotlin
Andriod dev toolbox part 2
Android dev toolbox
Know what (not) to build
Android ui tips & tricks

Recently uploaded (20)

PPT
Introduction Database Management System for Course Database
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Understanding Forklifts - TECH EHS Solution
PDF
System and Network Administration Chapter 2
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
ai tools demonstartion for schools and inter college
PPTX
Online Work Permit System for Fast Permit Processing
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
history of c programming in notes for students .pptx
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Nekopoi APK 2025 free lastest update
Introduction Database Management System for Course Database
Operating system designcfffgfgggggggvggggggggg
Understanding Forklifts - TECH EHS Solution
System and Network Administration Chapter 2
Navsoft: AI-Powered Business Solutions & Custom Software Development
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Design an Analysis of Algorithms II-SECS-1021-03
Wondershare Filmora 15 Crack With Activation Key [2025
ai tools demonstartion for schools and inter college
Online Work Permit System for Fast Permit Processing
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Design an Analysis of Algorithms I-SECS-1021-03
Internet Downloader Manager (IDM) Crack 6.42 Build 41
history of c programming in notes for students .pptx
Upgrade and Innovation Strategies for SAP ERP Customers
ManageIQ - Sprint 268 Review - Slide Deck
2025 Textile ERP Trends: SAP, Odoo & Oracle
Nekopoi APK 2025 free lastest update

“Micro Frontends”- You Keep Using That Word, I Don’t Think It Means What You Think It Means

Editor's Notes

  • #10: PxWe
  • #12: One possible solution- Fast forward months/ years: everyone frustrated, starting from scratch is inevitable.
  • #16: You start with a small app, it’s all nice The product is getting bigger and the single team working on the project is starting to form some structure and patterns The project gets even bigger, the single team that was responsible can’t keep up with the pace of change Code getting bigger exponentially, complexity is too big to manage, code is duplicated all around the place and developers velocity and happiness is low
  • #23: One of the engineers come up with an amazing idea (usually someone with a server side background): micro-services for front-end! =0
  • #24: The code is running on the client side, so all the frameworks overhead counts. The user should feel this is a single app The heavy lifting that you do on the server side can’t happen in the client side. Bundle size is an issue, so you want to “reuse” libraries between services, while keeping those isolated There’s no standard API to communicate between apps in the client side.
  • #30: There are actually a few, but each aims to solve different problems. Thus- before we pick one we need to understand what we want to solve and what are the prerequisites
  • #32: Do we know that all teams will use the same framework (and same version)? Do we want single deploy for all the app or independent deploy for each module? Do we want to be framework agnostic? Do we want to have modules that can be shared between different apps? Do we want to turn on and off modules? Should it be dynamic? Do we need to support SSR? Automatic tools (flow, CI, testing infra, redux patterns, utils, global apis) VS. Freedom (teams moving at their own speed, choosing their libraries, choosing their stacks, etc)
  • #37: Use peerDependencies
  • #40: Use peerDependencies
  • #43: Use peerDependencies
  • #46: Use peerDependencies
  • #49: Use peerDependencies
  • #52: Use peerDependencies