Skip to content

lazarkulasevic/growthbook-feature-flags

Repository files navigation

Real-time Feature Flags management with Growthbook

Integration with Growthbook is very simple. First refer to the Growthbook docs and install React package:

npm install --save @growthbook/growthbook-react

Configuration

Initiate Growthbook instance that will establish communication with the Growthbook API that returns your JSON config per environment.

const growthbook = new GrowthBook({
  apiHost: import.meta.env.VITE_GROWTHBOOK_API_HOST,
  clientKey: import.meta.env.VITE_GROWTHBOOK_CLIENT_KEY,
  enableDevMode: import.meta.env.DEV,
  subscribeToChanges: true,
})

Usage

Simplest way is to use Growthbook hook to dictate feature behavior.

const featureEnabled = useFeatureIsOn("feature_key")

Result: PROD & DEV

image

Growthbook Features

features