SDK Integration
How the GrowthBook SDK works
Section titled “How the GrowthBook SDK works”The GrowthBook SDK follows a fetch-once, evaluate-locally model. When your app starts, the SDK connects to the GrowthBook API and downloads a compact JSON bundle called feature definitions — all the flags, rules, and experiment configurations for your project. After that initial fetch, every flag evaluation happens entirely inside your app. There is no network round-trip per call.
Here is the end-to-end flow:
- GrowthBook UI — you create flags, configure targeting rules, and publish changes.
- GrowthBook CDN — stores the compiled feature definitions for each SDK key.
- SDK
init()— your app fetches and caches those definitions on startup. isOn()/getFeatureValue()— every evaluation reads from the local cache; no network call.
This architecture keeps flag evaluation fast (sub-millisecond), works offline after the first fetch, and scales to any request volume without adding load to GrowthBook.
What this module covers
Section titled “What this module covers”| Lesson | What you will learn |
|---|---|
| JavaScript SDK | Installing the vanilla SDK, initialising it, setting attributes, and evaluating flags in any JS environment |
| React SDK | The GrowthBookProvider, the useFeatureIsOn hook, and feature-flag patterns in React components |
| Node.js / Server-side | Per-request GrowthBook instances and safe server-side evaluation |
| Streaming & Caching | Real-time flag updates with Server-Sent Events and cache strategy options |
Supported platforms
Section titled “Supported platforms”The GrowthBook SDK is available for every major language and platform:
- JavaScript / TypeScript — browser and Node.js
- React — hooks and context provider
- React Native — mobile apps
- Go — server-side
- Python — server-side
- Ruby — server-side
- PHP — server-side
- iOS (Swift) — native mobile
- Android (Kotlin) — native mobile
- Flutter — cross-platform mobile
A minimal initialisation
Section titled “A minimal initialisation”The two required config values are apiHost (the CDN endpoint) and clientKey (the SDK key for your environment, found in GrowthBook under SDK Connections).
import { GrowthBook } from '@growthbook/growthbook';
const gb = new GrowthBook({
apiHost: 'https://cdn.growthbook.io',
clientKey: 'sdk-abc123',
});
await gb.init({ timeout: 2000 });
// Definitions are now cached locally — evaluate away
console.log(gb.isOn('my-flag')); // true or false, no network call