In this part, we will create a react application that consumes the design system. The app will have the capability to display itself as a standalone app or as a micro frontend in shell application.
Developing a React App with Mounting Capabilities
The idea here is to create a react app that does not automatically mount to DOM but rather assigns two functions mount
and unmount
to a property on the window object. The page that wants to display this app will call mount
function and give it a host DOMElment plus some configuration. In our case, the configuration will be one property isStandAlone
that will indicate if the app should display its own shell or as embedded micro fronted. We will also create an `index.html` file which will be deployed along with the application. If someone tries to access our app directly, the server will serve index.html
. HTML will contain a small script that will set up our app in stand-alone mode.
Creating the Nutrition Portal Directory
Create directory nutrition-portal
in the same folder as design-systme
(next to each other).
Setting Up Project Dependencies
Run following commands from nutrition-portal
directory to setup project dependencies: