Documentation Index
Fetch the complete documentation index at: https://growthbook-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Get GrowthBook running in your application in minutes.
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-).
1
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
1
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>
);
}
1
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>
);
}
Next steps: - See the example Next.js app - See the React SDK docs
1
Get your SDK Client Key
Go to SDK Configuration, create a new SDK Connection, and copy the Client Key (starts with sdk-).
1
Install the SDK
npm install @growthbook/growthbook
yarn add @growthbook/growthbook
pnpm add @growthbook/growthbook
bun add @growthbook/growthbook
1
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();
1
Use feature flags
if (gb.isOn("new-feature")) {
showNewFeature();
}
const color = gb.getFeatureValue("button-color", "blue");
Next steps: - See the JavaScript SDK docs for TypeScript, plugins, and more. - See an example Typescript app
1
Get your SDK Client Key
Go to SDK Configuration, create a new SDK Connection, and copy the Client Key (starts with sdk-).
1
Install the SDK
npm install @growthbook/growthbook
yarn add @growthbook/growthbook
pnpm add @growthbook/growthbook
bun add @growthbook/growthbook
1
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});
1
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);
Next steps: - See the full Node.js SDK docs - Use the SDK in Express middleware
1
Get your SDK Client Key
Go to SDK Configuration, create a new SDK Connection, and copy the Client Key (starts with sdk-).
1
Install the SDK
1
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",
}
)
1
Use feature flags
if await client.is_on("new-feature", user):
show_new_feature()
color = await client.get_feature_value("button-color", "blue", user)
Next steps: - See the full Python SDK docs - See the how to integrate with FastAPI example.
All SDKs
Client
[### HTML Script Tag
Drop-in script for any website](/lib/script-tag)[### JavaScript
Vanilla JS and TypeScript](/lib/js)[### React
Hooks and providers with SSR](/lib/react)[### Vue
Vue 3 composables](/lib/vue)[### Kotlin (Android)
Native Android](/lib/kotlin)[### Swift (iOS)
Native iOS](/lib/swift)[### Flutter
Cross-platform mobile](/lib/flutter)[### React Native
Cross-platform React](/lib/react-native)
Server
[### Node.js
Express, Fastify, etc.](/lib/node)[### Python
Flask, Django, FastAPI](/lib/python)[### Ruby
Rails and Ruby apps](/lib/ruby)[### PHP
Laravel, Symfony, etc.](/lib/php)[### Java
Spring Boot and Java](/lib/java)[### Go
High-performance Go](/lib/go)[### C#
.NET Core and ASP.NET](/lib/csharp)[### Elixir
Phoenix and Elixir](/lib/elixir)[### Rust
Actix, Axum, Rocket, and more](/lib/rust)
Edge
[### Cloudflare Workers
Edge computing on Cloudflare](/lib/edge/cloudflare)[### Fastly Compute
WebAssembly-powered edge](/lib/edge/fastly)[### Lambda@Edge
AWS CloudFront edge](/lib/edge/lambda)
Verify your setup
After setting up your SDK, verify it’s working by following these steps:
- Create a feature flag called
test-flag in your GrowthBook
- Set its value to
true and enable it for your environment
- Check that
isOn("test-flag") returns true in 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.