The Formo React Native SDK is designed for mobile dApps and implements the standard Events API with rich mobile context including device information, network status, and app metadata.Documentation Index
Fetch the complete documentation index at: https://docs.formo.so/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Install the SDK and its required peer dependency:Optional dependencies
For automatic device info detection (version, build number, device model), install one of:app option instead.
iOS Setup (bare React Native only)
If you’re using bare React Native (not Expo), run pod install after adding native dependencies:Expo projects handle native linking automatically — no
pod install needed.Quick Start
Basic Setup
Wrap your app with theFormoAnalyticsProvider:
With Wagmi
For apps using Wagmi, enable native integration for automatic wallet event tracking:Track screen views
Use thescreen() method to track screen views — the mobile equivalent of page views:
screen() method signature is:
Include
formo in the dependency array. The SDK initializes asynchronously, so including it ensures the screen event fires once initialization completes.With React Navigation
Automatically track all screen transitions:Mobile lifecycle events
The SDK automatically tracks application lifecycle events following the Segment/RudderStack specification:| Event | When | Properties |
|---|---|---|
Application Installed | First app launch (no stored version) | version, build |
Application Updated | App version or build changed since last launch | version, build, previous_version, previous_build |
Application Opened | Every cold start and return from background | version, build, from_background, url (if deep linked) |
Application Backgrounded | App transitions to background | version, build |
asyncStorage to be provided for accurate install/update detection. To disable:
The SDK detects app version and build from
expo-application, react-native-device-info, or the app option (in that order). If none are available, version and build will be empty strings.Identify users
Callidentify() after a user connects their wallet:
When using Wagmi integration, wallet connections are automatically tracked. You only need to call
identify() manually if you want to associate additional user data or use a custom user ID.Track custom events
Track custom events with thetrack() method:
Code examples
React Native
examples/react-native
Deep link attribution
Parse UTM parameters and referral codes from deep links:- UTM parameters (
utm_source,utm_medium,utm_campaign,utm_term,utm_content) - Referral codes (
ref,referral,refcode,referrer_code)
myapp://home?utm_source=twitter&utm_campaign=launch&ref=friend123
Configuration
Provider props
| Prop | Type | Required | Description |
|---|---|---|---|
writeKey | String | Yes | Your Formo project write key. |
asyncStorage | AsyncStorage | Yes | AsyncStorage instance for persistent storage. |
options | Object | No | Configuration options (see below). |
disabled | Boolean | No | Disable the SDK entirely. |
onReady | Function | No | Callback when SDK is initialized. |
onError | Function | No | Callback when initialization fails. |
Options
App metadata
The SDK automatically detects app information from your app’s native configuration:app_name- from your app’s display nameapp_version- from your app’s version (e.g.,2.1.0)app_build- from your app’s build number (e.g.,42)app_bundle_id- from your bundle/package identifier
Tracking control
Control tracking behavior for different environments or chains:Autocapture
Control which wallet events are automatically captured:Logging
Enable debug logging during development:| Log Level | Description |
|---|---|
error | Error messages only. |
warn | Warning and error messages. |
info | Informative messages about normal operation. |
debug | Detailed diagnostic information. |
log | General log messages. |
Ready callback
Execute code when the SDK is fully initialized:Consent management
Comply with privacy regulations using built-in consent management:Wagmi integration
When Wagmi integration is enabled, the SDK automatically tracks:| Event Type | Without QueryClient | With QueryClient |
|---|---|---|
| Connect | Tracked | Tracked |
| Disconnect | Tracked | Tracked |
| Chain Change | Tracked | Tracked |
| Signatures | Not tracked | Tracked |
| Transactions | Not tracked | Tracked |
Mobile context
The SDK automatically enriches every event with mobile-specific context:| Field | Description |
|---|---|
os_name | Operating system (iOS, Android). |
os_version | OS version number. |
device_model | Device model (iPhone 14 Pro, Pixel 8). |
device_manufacturer | Device manufacturer (Apple, Google, Samsung). |
device_type | Device type (mobile, tablet). |
screen_width | Screen width in pixels. |
screen_height | Screen height in pixels. |
screen_density | Pixel density (devicePixelRatio). |
locale | Device language setting. |
timezone | Device timezone. |
wifi | Whether connected to WiFi. |
cellular | Whether connected to cellular. |
carrier | Mobile carrier name (when available). |
app_name | Your app name. |
app_version | Your app version. |
app_build | Your app build number. |
Session management
Reset the current user session:Manual event flushing
Force flush pending events (useful before app backgrounding):The SDK automatically flushes events when the app goes to background.
Verification
To verify the SDK is working:- Enable debug logging in development
- Trigger a screen view or custom event
- Check the console for event logs
- Verify events appear in the Activity page on your Formo dashboard
Peer dependencies
| Package | Version | Required |
|---|---|---|
react | >=18.0.0 | Yes |
react-native | >=0.70.0 | Yes |
@react-native-async-storage/async-storage | >=1.17.0 | Yes |
wagmi | >=2.0.0 | No (for Wagmi integration) |
@tanstack/react-query | >=5.0.0 | No (for signature/transaction tracking) |
expo-application | >=5.0.0 | No (for auto version/build detection in Expo) |
expo-device | >=5.0.0 | No (for device info in Expo) |
react-native-device-info | >=10.0.0 | No (for auto version/build detection in bare RN) |