Use this example application to integrate with the CloudBees platform and test feature management. After integrating, observe changes in the application UI as you update flag values in the platform.
In this example, the Rox SDK is already set up, and feature flags are implemented in the code.
To get started with the react-fm-example project, follow these steps:
git clone git@github.com:cloudbees-io/react-fm-example.gitUse your preferred IDE (for example, Visual Studio Code, WebStorm, or IntelliJ IDEA).
- In the CloudBees platform, go to Feature management > Flags.
- Select an application.
- Select the copy icon next to the SDK key.
Note:
If no SDK key is available:
- In the platform, go to Feature management > Flags.
- Select the installation instructions icon.
- Follow the installation steps. The SDK key appears once an application is linked to an environment.
- Close the installation panel and copy the SDK key.
Open the following file:
src/feature-management/FeatureFlagsProvider.tsx
Replace the placeholder with your SDK key, for example:
const sdkKey = "<YOUR-SDK-KEY>";Save the file.
You can use either Yarn or NPM.
yarn install
yarn devnpm install
npm run devAfter the application starts, open the URL displayed in your terminal to view the running application.
To verify integration, return to the SDK installation panel in the CloudBees platform UI and select Test integration.
Now that your application is running:
- In the CloudBees platform, select Feature management.
- Select your example application to view the imported feature flags.
| Flag name | Type | Description |
|---|---|---|
| showMessage | Boolean | Turns the message on or off. |
| message | String | Sets the message text. |
| fontSize | Number | Font size in pixels. Values: 12, 16, or 24. |
| fontColor | String | Font color. Values: red, green, or blue. |
Note:
If no flags are displayed, verify that the environment-specific SDK key is correctly added in
src/feature-management/FeatureFlagsProvider.tsx.
Save the file and restart the application.
- Select Feature management.
- Select the application.
- Select the vertical ellipsis next to a flag.
- Select Configure.
- Select the environment associated with your SDK key.
- Update the flag value and save your changes.
- Set Configuration status to On.
The updated flag value will appear in the application shortly.
You can run multiple SDK instances in one application, each with its own SDK key and environment. Each instance is isolated. Use this when you need to:
- Compare flags across environments without redeploying
- Support multi-tenant routing
- Combine server-side and client-side evaluations
To use multiple SDK keys:
- Retrieve the SDK keys for the environments you will use.
- Initialize a separate SDK instance for each key.
- Route requests to the appropriate instance (for example, by tenant or region).
- Perform register/fetch/stream setup on each instance as required by the SDK.
- Evaluate flags using the correct instance and a consistent user/context object.
- Tag logs or metrics by instance and shut down instances when not needed.
-
JavaScript SDK installation:
https://docs.cloudbees.com/docs/cloudbees-platform/latest/install-sdk/javascript-sdk -
Configure feature flags:
https://docs.cloudbees.com/docs/cloudbees-platform/latest/feature-management/flag-configuration