Skip to main content

Installation

Follow the AsyncStorage native setup to link the native module. Peer dependencies: React Native 0.68+, @react-native-async-storage/async-storage 1.0+

Setup

Flags are available immediately on launch from the local cache, with a background refresh running in parallel. This applies on subsequent launches even when the device is offline.

First launch

No cache exists on a fresh install, so flags start loading. Gate on isLoading from useFlagStatus if your app needs flags before it can render:
After the first snapshot is cached this won’t trigger again, even offline.

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.
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.

Offline support

The last successful snapshot is persisted locally and loaded on the next launch before any network activity.
  • origin is 'CACHE' while a background fetch is pending, 'SERVER' once it completes.
  • On fetch failure origin stays 'CACHE' and flags keep serving from the cached snapshot.

Foreground refresh

A snapshot refresh is triggered automatically when the app returns to the foreground. Flag changes made in the dashboard reach active users without requiring an app restart.