FlagsterFlagster

React

This library allows you to use Flagster within React projects with some components and hooks provided by the library.

Usage

npm install flagster-react

Create FlagsterProvider and wrap your app with it

import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { createFlagster, FlagsterProvider } from "flagster-react";
 
createRoot(document.getElementById("root")!).render(
	<StrictMode>
		<FlagsterProvider
			flagster={createFlagster()}
			config={{
				environment: "YOUR_ENVIRONMENT",
			}}
		>
			// Your app goes here
		</FlagsterProvider>
	</StrictMode>,
);

You can now access the flags in your components with some components provided by the library

import { FeatureEnabled } from "flagster-react";
 
const App = () => (
    <div>
        <FeatureEnabled name="github_auth">
            GitHub Auth is enabled
        </FeatureEnabled>
    </div>
);

On this page