Skip to main content

Installation

Peer dependencies: React 18+

Setup

Wrap your app root with OmniFlagsProvider. It fetches the flag snapshot and starts background polling.

Loading state

Hooks return defaultValue until the first snapshot arrives. If you need to gate rendering on that:
Most apps don’t need this. Hooks update in place once the snapshot arrives.
When using OmniFlagsProvider (Next.js App Router), flags are ready before the first render. isLoading will always be false and defaultValue fallbacks are never shown.

Hooks

useFlag

Boolean flag evaluation. Re-renders only when this flag’s value changes.

useFlagValue

Returns the typed value of any flag: string, number, or object.

useFlagVariant

Returns the full EvaluationResult (variant key, reason, and rule ID). Useful when you need to log evaluation details or branch on variant names directly.

useFlagStatus

Current state of the flag client.

useSetFlagContext

Sets a global evaluation context for the whole provider tree. Individual hook calls that pass their own context will be merged with it; per-call attributes win on conflict.
Clears on unmount.

Evaluation context

Attributes used to match targeting rules and assign rollout buckets. Pass per-hook or once globally via useSetFlagContext.
Any extra key-value pairs are forwarded to targeting rules as custom attributes.
Rollout and traffic splits require a bucketing key (customerId, agentId, etc.). Without one the SDK returns the flag’s default value with MISSING_TARGETING_KEY.