@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 experiment 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: "server" (each resolution is a network call, with the response cached), backed by AsyncStorage for persistence across launches. You can override with evaluationMode: "bundle" if you’d rather embed the full bundle.
Installation
pod install in the ios/ directory after adding @react-native-async-storage/async-storage.
Setup
traffical_sk_..., scopes sdk:read+sdk:write) — browser-safe. 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:| Priority | Source | When available | Staleness |
|---|---|---|---|
| 1 | Cached assignments (AsyncStorage) | After first successful resolve | Refreshed per session |
| 2 | localConfig bundle (baked into the app binary) | Always (compiled in) | As of the last app build |
| 3 | Caller defaults from getParams | Always | Hardcoded fallback |
localConfig bundle built during CI:
localConfig, then to caller defaults.
Device-info enrichment
The SDK can enrichcontext with device info — useful for OS-specific experiments and analytics:
osName eq "ios" for an iOS-only experiment, or appVersion gte "2.0.0" to scope a feature flag to a minimum version.
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
| Option | Type | Default | Description |
|---|---|---|---|
orgId, projectId, env, apiKey | — | required | Same as other SDKs |
evaluationMode | "bundle" | "server" | "server" | Mobile-friendly default |
localConfig | ConfigBundle | — | Embedded bundle for cold-start |
deviceInfoProvider | DeviceInfoProvider | — | Device-context enrichment |
storage | StorageProvider | AsyncStorage | Custom persistence |
Next steps
Mobile experiment pattern
Onboarding and in-app experiments.
How it works
Evaluation modes and resolution.