Switchflag
Platform

Flags

Feature flags support four types — boolean, string, number, and JSON — with per-environment configuration.

Overview

Feature flags are the core primitive in Switchflag. A flag has a key, a type, a default value, and per-environment configuration (enabled state + targeting rules).

Creating a flag

FieldDescriptionValidation
NameDisplay name1-100 characters
KeyCode identifierLowercase, numbers, hyphens. Unique per project.
TypeValue typeboolean, string, number, json
Default ValueFallback valueMust be valid for the type
DescriptionOptional notesUp to 500 characters

Flag types

TypeDefault ValueSDK TypeUse Case
booleantrue or falsegetFlag<boolean>On/off toggles
stringAny stringgetFlag<string>A/B variants, theme names
numberAny numbergetFlag<number>Limits, thresholds
jsonValid JSONgetFlag<{ ... }>Complex configs

Flag key

The key is what you use in code:

const result = await client.getFlag<boolean>('new-checkout-flow', ctx)

Keys must be:

  • Lowercase letters, numbers, and hyphens only (^[a-z0-9-]+$)
  • Unique within the project
  • 1-100 characters

Default value

The default value is the fallback when:

  • The flag is enabled but no targeting rules match (non-boolean types)
  • The flag has no environment configuration

For boolean flags, when the flag is enabled and no rules match, the value is true (not the default value). When disabled, boolean flags return false.

Per-environment state

When a flag is first created, it's disabled in all environments. You control:

  • Enabled/disabled — toggle independently per environment
  • Targeting rules — different rules per environment

See Targeting Rules for configuring rules.