Feature Flags: Overview
What is a Feature Flag?
Section titled “What is a Feature Flag?”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.
What this module covers
Section titled “What this module covers”| Lesson | What you will learn |
|---|---|
| Create a Flag | How to create a Feature in the GrowthBook UI and read it via the SDK |
| Flag Types | Boolean, string, number, and JSON value types — when to use each |
| Environments | Dev / staging / production — independent flag states and SDK keys |
| Default Values | What the SDK returns when no rule matches, and why a safe fallback matters |
A first taste: reading a flag in code
Section titled “A first taste: reading a flag in code”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
}