SDK Connection
An SDK Connection is how you authorize your application to fetch feature flags from GrowthBook. Each connection is scoped to an environment and a language/framework.
Creating an SDK Connection
Section titled “Creating an SDK Connection”- In the GrowthBook UI, go to Settings in the left sidebar.
- Click SDK Connections.
- Click Add SDK Connection.
- Give it a name (e.g., “Node.js Dev”).
- Select the Environment (e.g.,
development). - Select the Language / Framework (e.g., JavaScript/Node.js).
- Click Save. GrowthBook shows you two values:
- apiHost — for self-hosted:
http://localhost:3100; for Cloud:https://cdn.growthbook.io. - clientKey — a string starting with
sdk-....
- apiHost — for self-hosted:
- Copy both values. You will use them to initialize the SDK.
import { GrowthBook } from '@growthbook/growthbook';
const gb = new GrowthBook({ apiHost: 'http://localhost:3100', // self-hosted SDK API clientKey: 'sdk-YOUR_CLIENT_KEY',});
await gb.init({ timeout: 2000 });
// Check a boolean flagif (gb.isOn('my-feature')) { console.log('Feature is enabled');}import { GrowthBook } from '@growthbook/growthbook';
const gb = new GrowthBook({
apiHost: 'http://localhost:3100', // self-hosted SDK API
clientKey: 'sdk-YOUR_CLIENT_KEY',
});
await gb.init({ timeout: 2000 });
// Check a boolean flag
if (gb.isOn('my-feature')) {
console.log('Feature is enabled');
}