Environments
What are environments?
Section titled “What are environments?”GrowthBook ships with three built-in environments: development, staging, and production. An environment is a named context that:
- Holds its own flag state (enabled/disabled, override rules).
- Has its own SDK Connection with a unique
clientKey.
This means a flag can be on in development and off in production at the same time — no deploys needed to move it between stages.
Admins can also add custom environments (e.g. qa, canary) from Settings → Environments.
Per-environment flag toggles
Section titled “Per-environment flag toggles”Every Feature has an environment-level toggle:
- Open a Feature in GrowthBook.
- Scroll to the Environments section. You will see rows for each environment.
- Click the toggle next to production to enable the flag there.
- The flag state in development and staging is unchanged.
Override rules (forcing a value, running an experiment, doing a percentage rollout) are also per-environment — a rule in development does not affect production.
SDK Connections — one clientKey per environment
Section titled “SDK Connections — one clientKey per environment”Navigate to Settings → SDK Connections to see one connection per environment. Each connection has a unique clientKey. Use the right key in each deployment context:
// Development appconst gb = new GrowthBook({ apiHost: 'https://cdn.growthbook.io', clientKey: 'sdk-dev-abc123',});
// Production appconst gb = new GrowthBook({ apiHost: 'https://cdn.growthbook.io', clientKey: 'sdk-prod-xyz789',});Typically you store the clientKey in an environment variable and inject it at build/runtime:
const gb = new GrowthBook({ apiHost: 'https://cdn.growthbook.io', clientKey: process.env.GROWTHBOOK_CLIENT_KEY,});// .env.development
// GROWTHBOOK_CLIENT_KEY=sdk-dev-abc123
// .env.production
// GROWTHBOOK_CLIENT_KEY=sdk-prod-xyz789
import { GrowthBook } from '@growthbook/growthbook';
const gb = new GrowthBook({
apiHost: 'https://cdn.growthbook.io',
clientKey: process.env.GROWTHBOOK_CLIENT_KEY,
});
await gb.init({ timeout: 2000 });
// Same flag key works across all environments.
// The value returned depends on which environment
// the clientKey belongs to.
const isOn = gb.isOn('my-flag');Creating an additional SDK Connection
Section titled “Creating an additional SDK Connection”- Go to Settings → SDK Connections.
- Click Add SDK Connection.
- Give it a name (e.g.
Production Node), select the production environment, and choose the SDK language. - Copy the generated
clientKeyand store it securely as an environment variable in your production deployment.