This is a sample micro frontend application that demonstrates how to manage React component states using either a single or multiple instances of the LaunchDarkly React Web client SDK.
The application consists of the following packages:
components
: Shared React components used by the micro frontendscontent
: A micro frontend that displays the main content of the applicationshell
: The shell application that integrates the micro frontends
- NodeJS >=v16.x
- React >=v18.x
- Webpack >=v5.x
- LaunchDarkly Account
Create the following projects and feature flags in your LaunchDarkly account using the specified project and flag keys.
Project | Flag Key | Flag Type | Description |
---|---|---|---|
project-1, project-2 | simple-toggle | boolean | Toggles flag status on page components |
project-1, project-2 | enable-message | boolean | Toggles message displayed in the body component |
project-1 | enable-new-header | boolean | Toggles new Header component |
Note: A Terraform configuration is available in
./terraform
for provisioning the projects and flags.
Update the root project.json
file and set your LaunchDarkly project client-side IDs:
{
"scripts": {
"start:content": "CONTENT_CLIENT_ID=\"Client side ID\" npm --prefix packages/content start",
"start:shell": "SHELL_CLIENT_ID=\"Client side ID\" npm --prefix packages/shell start"
}
}
Run the following commands to install the dependencies for each package:
npm run install:components
npm run install:content
npm run install:shell
To start the application, run the following npm scripts in separate terminals in the specified sequence:
npm run start:components
npm run start:content
npm run start:shell
The micro frontends and the shell application will be started, and you can access the application in your web browser