For the complete documentation index, see llms.txt. This page is also available as Markdown.

React Native integration

In plain English: this page is a collection of how-tos for the Amply React Native SDK beyond "just get it running." It covers peer dependencies, the iOS pod install step, Android autolinking, using the useAmplySystemEvents hook, cleaning up listeners so you don't leak memory, and handling re-initialization when the JS bundle reloads. A PM can skim the headings; an engineer copies the TypeScript snippets.

Use this when the React Native SDK is installed and you need to wire a specific flow. Don't use this when you haven't finished the Quickstart yet — start there.

Before you start

  • React Native 0.79+, Expo SDK 54+ (or bare RN 0.79+) — see Installation for the full requirements matrix.

  • New Architecture enabled (the SDK uses the new native module system).

  • Node 18+.

Peer dependencies and install

The SDK requires react >=18.2.0, react-native >=0.79.0, and expo >=54.0.0 as peer dependencies — make sure your app has them, then install:

npm install @amplytools/react-native-amply-sdk

iOS: run pod install

After installing the npm package, refresh the iOS native project. This links the native iOS SDK into your app.

cd ios
pod install
cd ..

Run this every time you change the installed npm version of the SDK.

Android: autolinking is automatic

On Android there is no manual Gradle edit. The SDK ships a react-native.config.js entry that React Native's autolinking picks up on the next build. Just rebuild:

If you use Expo with expo prebuild, the SDK's config plugin registers the native package for you during prebuild.

Initialize once, early

Call initialize once, as close to app start as possible. The function returns a Promise that resolves when the native SDK is ready.

Signature:

Amply.isInitialized() returns true synchronously once initialize has resolved.

Custom property value types

RN custom properties accept string | number | boolean only. The iOS and Android native SDKs accept more types — stick to primitives on React Native.

Re-init on Fast Refresh / JS reload

Pressing R in Metro re-runs your JS bundle but the native side stays alive. The native SDK remains initialized across JS reloads. Guarding your init is optional but keeps logs clean:

On a cold launch, both JS and native start fresh — always call initialize on mount.

Listening to system events

System events are SDK lifecycle signals: config loaded, session started, campaign evaluated. Two APIs are available.

Option 1: the hook (good for debug UI)

Signature:

Option 2: the raw listener (good for production)

Returns a Promise that resolves to an unsubscribe function.

Signature:

Same Promise-returns-unsubscribe shape.

Signature:

Declare your URL scheme in Info.plist and AndroidManifest.xml — see iOS integration and Android integration.

Tracking events and identifying the user

See Tracking events and User attributes for payload rules.

Tearing down all listeners

For hard resets (user logs out, tests):

This clears every deeplink subscription the SDK is currently tracking. It does not uninitialize the SDK.

Log level

Debug logging is forwarded to console automatically when the level is not 'none'.

Last updated