Feature flags
Server-controlled boolean and variant flags with attached JSON payload, plus hooks for React.
Feature flags let you ship code dark and turn it on without a deploy. Today each flag has a global on/off and a global default variant — every user who fetches the flag set sees the same answer. Per-user targeting (segment-scoped flags, sticky A/B variants) is on the roadmap; the SDK contract is already shaped for it so client code won't need to change when it lands.
Two flag types:
- Boolean flags — global on / off. Read with
useFlag(name)orflags.fetch().then(...). - Variant flags — return a string (e.g.
'control'/'short'/'long'). Today the variant is the same for every user, so use these for kill-switched rollouts and config-as-flag, not as A/B traffic splitters yet.
Each flag can also carry a payload JSON value — useful for config-driven feature gates ({ "max_items": 25 }).
Coming next: per-user targeting
Segment-scoped flags and sticky A/B variants are tracked work. Until they ship, treat flags as global kill-switches plus attached config — not as A/B traffic splitters. If you ship a multi-variant flag today, every user gets the same arm.
Quick start
Operations
fetch()
Returns the full flag set for this project. Each entry has the shape:
Every fetch() call sends a request to the server. Hold the result yourself when you read flags often, as in the module-scope pattern below.
Today every signed-in user receives the same project-wide set of enabled flags. When per-user targeting ships, the response shape stays the same and the values start varying by user.
React hooks
useFlag(name) returns the flag's assignment ({ name, enabled, variant, payload }), or null when the flag is unknown, disabled, or still loading; read useFlag(name)?.enabled ?? false for a boolean. useVariant(name) returns the variant string (or null if unset / not loaded).
Both hooks return null while the initial fetch is in flight, so the ?.enabled ?? false read renders the gated UI hidden until flags load.
Patterns
Gate render at module scope
For flags that gate large slabs of the UI, prefer fetching once at app start and stashing the result:
Config-driven gates
For A/B tests with parameterized behavior, attach a payload to the variant in the console and read it on the client:
Server-side parity
Server functions read the same flag set from the client endpoint GET /v1/client/flags, authenticated with your server key as X-Api-Key plus X-On-Behalf-Of: <user id>. Store the server key as a function secret under your own name (amba secrets set APP_SERVER_KEY <server key> --function <fn>); names starting with AMBA_ are reserved for values the platform injects. Useful for gating server logic on the same answer as the UI:
Limits
- Flag count: up to 100 flags per project visible to a single fetch.
- Variant count: up to 8 variants per multi-variant flag (
control+ 7 treatments is a common ceiling). - Payload size: up to 8 KB JSON per flag.
- Caching: none in the SDK; each
fetch()is a request.
Reference
GET /v1/client/flagsandGET /v1/client/flags/:key— the client endpoints behindfetch()andget().- Auth feature — prerequisite.
- Config feature — for non-flag remote config bundles.
- Per-platform quickstarts: Web, Node, iOS, Android, Flutter, Unity.