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

npm version

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

Bare React Native

npm install @adopture/react-native @react-native-async-storage/async-storage react-native-get-random-values
cd ios && pod install

Optional dependencies

PackagePurpose
@react-native-community/netinfoPause sending when offline, auto-flush on reconnect
@react-navigation/nativeAutomatic screen tracking via useAdoptureNavigationTracking
expo-localizationDetect device locale
expo-constantsDetect app version

Quick Setup

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

PlatformSupported
AndroidYes
iOSYes

React Hooks Reference

import {
  AdoptureProvider,
  useAdopture,
  useTrack,
  useScreen,
  useIdentify,
  useAdoptureNavigationTracking,
} from '@adopture/react-native/react';
HookReturns
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

On this page