Skip to content

Create a Flag

A Feature in GrowthBook maps directly to a feature flag in your code. Here is how to create one from scratch.

  1. Log in to GrowthBook at http://localhost:3000 (or your Cloud URL).
  2. In the left sidebar, click Features.
  3. Click the Add Feature button in the top-right corner.
  1. Feature Key — enter a lowercase, hyphen-separated identifier, e.g. my-flag. This is the string your code will use forever — choose carefully.
  2. Value Type — select Boolean for a simple on/off flag.
  3. Default Value — set it to false (off by default everywhere).
  4. Click Create Feature.

Step 3 — Enable the flag in an environment

Section titled “Step 3 — Enable the flag in an environment”

By default, your flag exists but is disabled in all environments.

  1. On the Feature detail page, find the Environments section. You will see rows for development, staging, and production.
  2. Click the toggle next to development to switch it from Disabled to Enabled.
  3. Because there are no override rules, every user will receive the default value of true in development.

Tip: You can set a per-environment default that is different from the global default. This lets you ship true in development while keeping false in production until you are ready.

Once the feature exists in GrowthBook, use the SDK to evaluate it:

import { GrowthBook } from '@growthbook/growthbook';
const gb = new GrowthBook({
apiHost: 'https://cdn.growthbook.io',
clientKey: 'sdk-YOUR_DEV_KEY',
});
await gb.init({ timeout: 2000 });
if (gb.isOn('my-flag')) {
console.log('Flag is ON');
} else {
console.log('Flag is OFF');
}

For boolean flags you can also use getFeatureValue, which requires an explicit fallback:

const flagValue = gb.getFeatureValue('my-flag', false);
// returns true or false, never throws
import { GrowthBook } from '@growthbook/growthbook';

const gb = new GrowthBook({
  apiHost: 'https://cdn.growthbook.io',
  clientKey: 'sdk-YOUR_DEV_KEY',
});

await gb.init({ timeout: 2000 });

// boolean shorthand
if (gb.isOn('my-flag')) {
  console.log('Flag is ON');
}

// explicit value with fallback
const flagValue = gb.getFeatureValue('my-flag', false);
Where in the GrowthBook UI do you create a new Feature?
What is the purpose of the Default Value on a Feature?
Which SDK method requires an explicit fallback argument?
What happens if you rename a Feature key in GrowthBook after deploying?