New to GrowthBook SDKs?The SDK Overview covers how SDKs work and helps you choose the right one for your use case.
- React
- JavaScript
- Node.js
- Python
- 22+ More SDKs
1
Get your SDK Client Key
Go to SDK Configuration, create a new SDK Connection, and copy the Client Key (starts with
sdk-).2
Install the SDK
npm install @growthbook/growthbook-react @growthbook/growthbook
yarn add @growthbook/growthbook-react @growthbook/growthbook
pnpm add @growthbook/growthbook-react @growthbook/growthbook
bun add @growthbook/growthbook-react @growthbook/growthbook
3
Wrap your app with `GrowthBookProvider`
import { GrowthBook, GrowthBookProvider } from "@growthbook/growthbook-react";
import { thirdPartyTrackingPlugin, autoAttributesPlugin } from "@growthbook/growthbook/plugins";
// Create a GrowthBook instance
const gb = new GrowthBook({
apiHost: "https://cdn.growthbook.io",
clientKey: "sdk-abc123", // Your SDK client key
enableDevMode: true,
plugins: [
thirdPartyTrackingPlugin(), // Optional, sends "Experiment Viewed" events via GrowthBook Managed Warehouse, Google Analytics, Google Tag Manager, and Segment.
autoAttributesPlugin(), // Optional, sets common attributes (browser, session_id, etc.)
],
});
// Load feature definitions from the GrowthBook API
gb.init();
export default function App() {
return (
<GrowthBookProvider growthbook={gb}>
<MyApp />
</GrowthBookProvider>
);
}
4
Use feature flags
import { useFeatureIsOn, useFeatureValue } from "@growthbook/growthbook-react";
function MyApp() {
const showNewFeature = useFeatureIsOn("new-feature");
const buttonColor = useFeatureValue("button-color", "blue");
return (
<div>
{showNewFeature && <NewFeature />}
<button style={{ backgroundColor: buttonColor }}>Click me</button>
</div>
);
}
1
Get your SDK Client Key
Go to SDK Configuration, create a new SDK Connection, and copy the Client Key (starts with
sdk-).2
Install the SDK
npm install @growthbook/growthbook
yarn add @growthbook/growthbook
pnpm add @growthbook/growthbook
bun add @growthbook/growthbook
3
Initialize GrowthBook
import { GrowthBook } from "@growthbook/growthbook";
import { thirdPartyTrackingPlugin, autoAttributesPlugin } from "@growthbook/growthbook/plugins";
const gb = new GrowthBook({
apiHost: "https://cdn.growthbook.io",
clientKey: "sdk-abc123",
plugins: [
thirdPartyTrackingPlugin(), // Optional, sends "Experiment Viewed" events via GrowthBook Managed Warehouse, Google Analytics, Google Tag Manager, and Segment.
autoAttributesPlugin(), // Optional, sets common attributes (browser, session_id, etc.)
],
});
await gb.init();
4
Use feature flags
if (gb.isOn("new-feature")) {
showNewFeature();
}
const color = gb.getFeatureValue("button-color", "blue");
1
Get your SDK Client Key
Go to SDK Configuration, create a new SDK Connection, and copy the Client Key (starts with
sdk-).2
Install the SDK
npm install @growthbook/growthbook
yarn add @growthbook/growthbook
pnpm add @growthbook/growthbook
bun add @growthbook/growthbook
3
Initialize GrowthBook
import { GrowthBookClient } from "@growthbook/growthbook";
const gbClient = new GrowthBookClient({
apiHost: "https://cdn.growthbook.io",
clientKey: "sdk-abc123",
trackingCallback: (experiment, result, userContext) => {
const userId = userContext.attributes.id;
// Required for A/B testing
// TODO: Replace with your own tracking implementation
console.log("Viewed Experiment", userId, {
experimentId: experiment.key,
variationId: result.key
});
}
});
await gbClient.init({timeout: 3000});
4
Use feature flags
// User context with attributes that feature flags can use for targeting
const userContext = {
attributes: {
id: "123",
country: "US",
// ... other attributes ...
}
}
// Boolean on/off flags
if (gbClient.isOn("my-feature", userContext)) {
console.log("My feature is on!");
}
// String, Number, or JSON flags
const value = gbClient.getFeatureValue("my-string-feature", "fallback", userContext);
console.log(value);
1
Get your SDK Client Key
Go to SDK Configuration, create a new SDK Connection, and copy the Client Key (starts with
sdk-).2
Install the SDK
pip
pip install growthbook
3
Initialize GrowthBook
from growthbook import GrowthBookClient, Options, UserContext
def on_experiment_viewed(experiment, result):
# TODO: track in your analytics system
print(f"Experiment: {experiment.key}, Variation: {result.key}")
# Create and initialize client
client = GrowthBookClient(
Options(
api_host="https://cdn.growthbook.io",
client_key="sdk-abc123",
on_experiment_viewed=on_experiment_viewed,
)
)
await client.initialize()
# Create user context for targeting
user = UserContext(
attributes={
"id": "user-123",
"country": "US",
}
)
4
Use feature flags
if await client.is_on("new-feature", user):
show_new_feature()
color = await client.get_feature_value("button-color", "blue", user)
All SDKs
ClientHTML Script Tag
Drop-in script for any website
JavaScript
Vanilla JS and TypeScript
React
Hooks and providers with SSR
Vue
Vue 3 composables
Kotlin (Android)
Native Android
Swift (iOS)
Native iOS
Flutter
Cross-platform mobile
React Native
Cross-platform React
Node.js
Express, Fastify, etc.
Python
Flask, Django, FastAPI
Ruby
Rails and Ruby apps
PHP
Laravel, Symfony, etc.
Java
Spring Boot and Java
Go
High-performance Go
C#
.NET Core and ASP.NET
Elixir
Phoenix and Elixir
Rust
Actix, Axum, Rocket, and more
Cloudflare Workers
Edge computing on Cloudflare
Fastly Compute
WebAssembly-powered edge
Lambda@Edge
AWS CloudFront edge
Verify your setup
After setting up your SDK, verify itβs working by following these steps:- Create a feature flag called
test-flagin your GrowthBook - Set its value to
trueand enable it for your environment - Check that
isOn("test-flag")returnstruein your app - Toggle the flag off and verify the change is reflected
Use the GrowthBook DevTools browser extension to inspect and test feature flags in development.

