SDKsReact Native
React Native SDK
Install and set up the Adopture React Native SDK in your app.
The Adopture React Native SDK adds privacy-first analytics to your React Native and Expo apps. Pure JavaScript — no native modules required.
Requirements
- React Native >= 0.70
- React >= 18
- Expo SDK 50+ (if using Expo)
Installation
Expo
npx expo install @adopture/react-native @react-native-async-storage/async-storage react-native-get-random-valuesBare React Native
npm install @adopture/react-native @react-native-async-storage/async-storage react-native-get-random-values
cd ios && pod installOptional dependencies
| Package | Purpose |
|---|---|
@react-native-community/netinfo | Pause sending when offline, auto-flush on reconnect |
@react-navigation/native | Automatic screen tracking via useAdoptureNavigationTracking |
expo-localization | Detect device locale |
expo-constants | Detect app version |
Quick Setup
With React hooks (recommended)
Wrap your app in AdoptureProvider:
import { AdoptureProvider } from '@adopture/react-native/react';
export default function App() {
return (
<AdoptureProvider appKey="ak_your_app_key_here">
<MainApp />
</AdoptureProvider>
);
}Then use hooks in any component:
import { useTrack, useIdentify } from '@adopture/react-native/react';
function MainApp() {
const track = useTrack();
const identify = useIdentify();
const handleSignIn = async (userId: string) => {
await identify(userId);
track('signed_in', { method: 'email' });
};
return <Button title="Sign In" onPress={() => handleSignIn('user-123')} />;
}Without React hooks
import { Adopture } from '@adopture/react-native';
await Adopture.init({ appKey: 'ak_your_app_key_here' });
Adopture.track('button_pressed', { screen: 'home' });
Adopture.screen('settings');
await Adopture.identify('user-123');That's it. The SDK automatically tracks sessions, collects device context, and queues events for delivery.
Supported Platforms
| Platform | Supported |
|---|---|
| Android | Yes |
| iOS | Yes |
React Hooks Reference
import {
AdoptureProvider,
useAdopture,
useTrack,
useScreen,
useIdentify,
useAdoptureNavigationTracking,
} from '@adopture/react-native/react';| Hook | Returns |
|---|---|
useAdopture() | The Adopture class for direct access |
useTrack() | Stable (name, properties?) => void |
useScreen() | Stable (name, properties?) => void |
useIdentify() | Stable (userId) => Promise<void> |
useAdoptureNavigationTracking(ref) | Void — auto-tracks screen changes |
Next Steps
- Configuration — Customize flush intervals, queue sizes, and debug mode
- Tracking Events — Track custom events and screen views
- Navigation Tracking — Automatically track screen views with React Navigation