Installation
Setup
Wrap your app root withOmniFlagsProvider. It fetches the flag snapshot and starts background polling.
- Vite / CRA
- Next.js (App Router)
- Next.js (Pages Router)
Loading state
Hooks returndefaultValue until the first snapshot arrives. If you need to gate rendering on that:
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.
Evaluation context
Attributes used to match targeting rules and assign rollout buckets. Pass per-hook or once globally viauseSetFlagContext.
Any extra key-value pairs are forwarded to targeting rules as custom attributes.