Skip to content

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.

  1. In the GrowthBook UI, go to Settings in the left sidebar.
  2. Click SDK Connections.
  3. Click Add SDK Connection.
  4. Give it a name (e.g., “Node.js Dev”).
  5. Select the Environment (e.g., development).
  6. Select the Language / Framework (e.g., JavaScript/Node.js).
  7. 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-....
  8. 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 flag
if (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');
}
What is the apiHost for a self-hosted GrowthBook SDK?
What does a clientKey look like?
Where do you create an SDK Connection in the GrowthBook UI?
Why use separate SDK Connections for development and production?