Skip to content

Feature Flags: Overview

A feature flag (also called a feature toggle) is a decision point in your code that lets you turn behaviour on or off without deploying new code. Instead of shipping a risky feature to everyone at once, you wrap it in a flag and control it from a dashboard.

In GrowthBook, a feature flag is called a Feature. Every Feature has:

  • A key — the stable string your code uses to look it up (e.g. new-checkout).
  • A value type — boolean, string, number, or JSON.
  • A default value — what the SDK returns when no rule matches.
  • Rules per environment — who sees which value, and when.
LessonWhat you will learn
Create a FlagHow to create a Feature in the GrowthBook UI and read it via the SDK
Flag TypesBoolean, string, number, and JSON value types — when to use each
EnvironmentsDev / staging / production — independent flag states and SDK keys
Default ValuesWhat the SDK returns when no rule matches, and why a safe fallback matters

GrowthBook ships SDKs for every major language and framework. Here is the minimal Node.js pattern:

import { GrowthBook } from '@growthbook/growthbook';
const gb = new GrowthBook({
apiHost: 'https://cdn.growthbook.io',
clientKey: 'sdk-abc123',
});
await gb.init({ timeout: 2000 });
if (gb.isOn('new-checkout')) {
// show the new checkout flow
} else {
// show the current checkout flow
}

The call gb.isOn('new-checkout') asks GrowthBook: “is the new-checkout flag on for the current user context?” The answer comes from the rules you configure in the GrowthBook UI — your code never hard-codes it.

import { GrowthBook } from '@growthbook/growthbook';

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

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

if (gb.isOn('new-checkout')) {
  // new checkout flow
} else {
  // current checkout flow
}
What is a GrowthBook Feature key used for?
What does gb.isOn("flag-name") return when no rule matches and the default value is false?
Which component shows the Docker Compose setup reminder in this course?