# React Native and Expo (https://talivia.com/docs/mobile-analytics/react-native)



Use `@talivia/react-native` for native iOS and Android apps built with React Native or Expo. For Expo Web, use the [Expo Web installation guide](https://talivia.com/docs/installation-guides/expo) instead.

## Install [#install]

```sh
npm install @talivia/react-native
```

For Expo, also install the storage and UUID adapters:

```sh
npx expo install @react-native-async-storage/async-storage expo-crypto
```

## Initialize and track [#initialize-and-track]

```tsx
import AsyncStorage from '@react-native-async-storage/async-storage';
import * as Crypto from 'expo-crypto';
import { Platform } from 'react-native';
import { Talivia } from '@talivia/react-native';

const analytics = new Talivia({
  websiteId: 'YOUR_WEBSITE_UUID',
  host: 'https://talivia.com',
  hostname: 'example.com', // use your website domain for a shared workspace
  platform: Platform.OS === 'ios' ? 'ios' : 'android',
  storage: AsyncStorage,
  uuid: prefix => `${prefix}_${Crypto.randomUUID()}`,
});

await analytics.init();
await analytics.screen('Home');
await analytics.track('signup_completed', { plan: 'pro' });
await analytics.identify('your-stable-user-id');
// On logout: await analytics.reset();
```

Call `screen()` from your React Navigation or Expo Router change callback. Call `track()` only after the action succeeds. For bare React Native, provide a storage adapter and secure UUID generator appropriate to your app; runtimes with `crypto.randomUUID` or `crypto.getRandomValues` do not need an explicit UUID adapter.

Initialize only when consent permits collection. Call `flush()` when connectivity returns if you want to retry queued events before the next app event. The retry queue is memory-only and capped at 100 events.

Using the same Website ID and hostname as web makes both sources visible in one Talivia workspace. `identify()` links known account identity records when the stable ID matches; current funnels still group by visitor token across devices. Install attribution and purchases are not captured automatically. Send verified revenue from your backend.

[See React Native analytics](https://talivia.com/mobile-app-analytics/react-native) · [View package source](https://github.com/talivia-group/react-native)
