(ISPI / PBE / LEFL)
Research on the use of different methods to integrate micro-frontends :
- With iframes
- With JavaScript
- With React only
- With Custom Elements (Web Components)
- Server-side Rendered
- Simple example - Express/EJS
- Advanced example - Express/EJS + sessionStorage + Redux/Vuex
- With Single-SPA Meta-framework (More information on Single-SPA's website)
Go to Micro-frontends/microfront-with-iframe/
- In
./ngapp
, use the commandnpm run dev
to launch the Angular app locally at http://localhost:5001/ - Idem in
./reactapp
&./vueapp
, which will launch respectively at http://localhost:5002/ & http://localhost:5003/ - Launch in
./wrapperapp
the global app usingnpm start
to see the result at http://localhost:5000/
This method uses React & Angular as Micro-frontends rendered server-side & plain JavaScript to compose Micro-frontends client-side
Go to Micro-frontends/microfront-with-js/
and like with Express/EJS :
- In the 3
./react-X
folders, executenpm run start:prod
This will launch 3 React micro-frontends at http://localhost:7001/, http://localhost:7002/ & http://localhost:7003/
- In the 2
./angularX
folders, also executenpm run start:prod
This will launch 2 Angular micro-frontends at http://localhost:7004/ & http://localhost:7005/
- In the root folder, launch the express server with
node server.js
View the result at http://localhost:7000/
This method uses React as Micro-frontends & to create Micro-frontends
Go to Micro-frontends/microfront-with-react/
:
- In each folder execute
npm start
This will launch 3 micro-frontends :
The container application (wrapperapp) at http://localhost:3000/,
Two micro-applications (microappX) at http://localhost:3001/ & http://localhost:3002/
The content server (common-content) at http://localhost:3100/ allows shared content across the micro-frontends such as libraries, CSS, JSON data...
- View the result at http://localhost:3000/
This method uses Direflow to create React Web Components, Angular Elements for Angular Web Components & @vue/web-component-wrapper for Vue Web Components
Go to Micro-frontends/microfront-with-webcomponents/
:
- In
./angular-app
,react-app
&vue-app
executenpm run dev
to build & launch the Angular, React & Vue Web Components at http://localhost:4001/, http://localhost:4002/ & http://localhost:4003/ - In
./common-content
runnpm start
to allow use of shared content serve at http://localhost:4100/ - In
./wrapper-app
runnpm start
to see an example of use of Custom Elements at http://localhost:4000/
Advanced Custom Elements example using a global state with Redux
This method uses Direflow to create React Web Components & @vue/web-component-wrapper for Vue Web Components
It also implements react-redux and vuejs-redux to handle communication with the store
Go to Micro-frontends/microfront-with-wc-redux/
:
-
In
react-app
&vue-app
executenpm run dev
to build & launch the React & Vue Web Components at http://localhost:4001/, http://localhost:4002/ -
In
./redux-app
runnpm start
to bundle all the redux logic in a single js file (thanks to rollup.js). The result is served at http://localhost:4100/ -
In
./wrapper-app
(a React application), runnpm start
to contain the micro-frontend and use a router allowing different lifecycles to our Web components. See the result at http://localhost:4000/
Advanced Custom Elements example using a global state with Vuex
This method uses Direflow to create React Web Components & @vue/web-component-wrapper for Vue Web Components
To handle communication between Vuex store & React, a script was created at .../react-app/vuex-react
with useful hooks, using React context
Go to Micro-frontends/microfront-with-wc-redux/
:
-
In
react-app
&vue-app
executenpm run dev
to build & launch the React & Vue Web Components at http://localhost:4001/, http://localhost:4002/ -
In
./vuex-app
runnpm start
to serve themain.js
file, which contains all the vuex logic in a json array file (with modifications for React). The result is served at http://localhost:4100/ -
In
./wrapper-app
, runnpm start
to see the result at http://localhost:4000/
This method uses React & Angular as Micro-frontends rendered server-side & EJS to compose Micro-frontends server-side
Go to Micro-frontends/microfront-with-express/
- In the 3
./react-X
folders, executenpm run start:prod
This will launch 3 React micro-frontends at http://localhost:8001/, http://localhost:8002/ & http://localhost:8003/
- In the
./angular
folders, also executenpm run start:prod
This will launch an Angular micro-frontends at http://localhost:8004/
-
In the root folder, launch the express server with
node server.js
-
View the result at http://localhost:8000/
Advanced Server-Side Rendered Micro-frontends using Next.js with Redux, Nuxt.js with Vuex and the sessionStorage to pass data from one page to the other
Go to Micro-frontends/microfront-with-ssr-storage/
- In the 2
./react-app-X
and thevue-app
folders, executenpm run build && npm run start
This will launch the 3 micro-frontends respectively at http://localhost:8001/, http://localhost:8002/ & http://localhost:8003/
-
In the
./common-content
folder, launch the server withnpm start
from which data will be fetched -
In the
./container-app
folder, launch the express server withnpm start
-
View the result at http://localhost:8000/
This method uses Single SPA framework & its helper libraries to create Micro-frontends
Go to Micro-frontends/microfront-with-single-spa/
:
-
In
angular-app
,react-app
,vue-app
&react-navbar
executenpm run dev
to build & launch the Angular, React and Vue 'Single SPAs' respectively at http://localhost:9001/, http://localhost:9002/, http://localhost:9003/ & http://localhost:9004/ -
In
./root-config
, runnpm start
to see the result at http://localhost:9000/