@traffical/react-native is the SDK for iOS and Android apps built with React Native. It handles the constraints mobile imposes — cold starts, offline use, app suspension, device context — and ships with sensible defaults so most apps don’t have to think about them.
Why mobile is different
Mobile has constraints web and backend don’t:- Cold start. On first launch there’s no cached bundle and no network response yet. The user sees the app before any policy can resolve.
- Offline use. Users open the app on planes and in subways. Resolution must work without connectivity.
- App store latency. Code changes take days. Parameter changes via Traffical are instant — this is the whole point of having a remote configuration system at all.
- Background suspension. The app may be paused for hours and resumed. Cached assignments need refreshing.
evaluationMode: "bundle" for mobile. The SDK fetches the config bundle once and resolves on-device, so every subsequent decision is local — no per-decision network call, and it keeps working offline. This is also the only mode that works with a publishable key, which is the key type that belongs in a mobile binary.
The package’s own default is still evaluationMode: "server", where each resolution is evaluated for that call’s context on the edge and the response is persisted to AsyncStorage across launches. Because getParams/decide are synchronous, a call returns the last-good cached response and converges as fresh resolves land. Server mode requires a server-side SDK key, so on mobile it means proxying through your own backend.
Installation
pod install in the ios/ directory after adding @react-native-async-storage/async-storage.
Setup
traffical_pk_...) — it is safe to ship in a mobile binary. The SDK auto-registers the AsyncStorage cache and lifecycle hooks for foreground/background transitions.
Resolving parameters
Same hook as the React SDK:Cold start strategy
Resolution checks three sources in order:
First launch, no localConfig: the user sees defaults until the first network call returns. If your first-launch onboarding is a critical test, embed a
localConfig bundle built during CI:
localConfig, then to caller defaults.
Device-info enrichment
The SDK can enrichcontext with device info — useful for OS-specific targeting and analytics. You supply the data through a deviceInfoProvider: any object implementing the DeviceInfoProvider interface. The returned fields merge into context on every resolution, so they’re available for policy conditions.
The default provider
defaultDeviceInfoProvider derives device metadata from React Native’s Platform and Dimensions plus Intl — no native modules. It is opt-in: nothing is added to your context unless you pass it.
$-prefixed system attributes shared by every Traffical SDK — registered in every project, so you can target them straight from the condition editor — plus un-prefixed fields for compatibility with existing conditions:
Values are re-read on every call, so rotation and locale changes are picked up on the next decision.
To populate
$app_version, build the provider with the version from your own source (expo-constants, react-native-device-info, or a generated constant):
Your own provider
ImplementDeviceInfoProvider yourself to add fields the default cannot read, typically backed by react-native-device-info:
$ keys in new conditions — e.g. $os eq "ios" for an iOS-only policy.
Tracking events
Foreground refresh
When the app returns to the foreground after being suspended, the SDK checks whether the cache is stale and refreshes silently if so. Existing assignments stay stable — the refresh only matters for new parameters or next-session resolutions.Options
Persistence is backed by
AsyncStorage automatically — the provider registers it for you, so there’s no storage option to set. The provider also accepts the common options shared with the other SDKs (trackDecisions, exposureSessionTtlMs, eventBatchSize, eventFlushIntervalMs, disableCloudEvents, assignmentLogger, unitKeyFn, contextFn, plugins).
Next steps
Mobile app pattern
Onboarding and in-app tests.
How it works
Evaluation modes and resolution.