Installation
@react-native-async-storage/async-storage 1.0+
Setup
First launch
No cache exists on a fresh install, so flags start loading. Gate onisLoading from useFlagStatus if your app needs flags before it can render:
Hooks
Same hooks as the React SDK, imported from@omniretail/omniflags-react-native.
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).
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.
Offline support
The last successful snapshot is persisted locally and loaded on the next launch before any network activity.originis'CACHE'while a background fetch is pending,'SERVER'once it completes.- On fetch failure
originstays'CACHE'and flags keep serving from the cached snapshot.