Skip to main content

React Native SDK for TypeScript

Add install tracking and purchase attribution to your React Native app. Works with Expo and bare React Native projects.

Quick start

Track your first install in under 5 minutes.

import { appfiliate } from 'appfiliate-react-native';

// On app startup:
appfiliate.configure({ appId: 'APP_ID', apiKey: 'API_KEY' });
await appfiliate.trackInstall();

Get your App ID and API Key from your Appfiliate dashboard.

Integration guide

Step-by-step instructions to integrate the Appfiliate React Native SDK.

1

Install the package

Install via npm or yarn:

npm install appfiliate-react-native
2

Configure and track installs

Find your app's root component or entry point (App.tsx or index.js). Add the following:

import { appfiliate } from 'appfiliate-react-native';
import { useEffect } from 'react';

export default function App() {
  useEffect(() => {
    async function initTracking() {
      appfiliate.configure({ appId: 'APP_ID', apiKey: 'API_KEY' });
      await appfiliate.trackInstall();
    }
    initTracking();
  }, []);

  return <MainNavigator />;
}

trackInstall() only fires once per install — it's safe to call on every launch.

3

Track purchases (optional)

After a successful in-app purchase, call trackPurchase():

await appfiliate.trackPurchase({
    productId: 'premium_monthly',
    revenue: 9.99,
    currency: 'USD',
    transactionId: purchase.transactionId,
});
4

Set user ID for webhooks (optional)

If you use RevenueCat, Superwall, Adapty, Qonversion, or Stripe, link the user ID so purchases are attributed automatically:

// RevenueCat example
await appfiliate.setUserId(await Purchases.getAppUserID());

// Stripe example
await appfiliate.setUserId(stripeCustomerId);

Automatic Purchase Tracking

RevenueCat webhook integration

Connect RevenueCat and every purchase, renewal, and cancellation is attributed automatically. No manual trackPurchase() calls needed.

1. Add one line of code

appfiliate.configure({ appId: 'APP_ID', apiKey: 'API_KEY' });
await appfiliate.trackInstall();
await appfiliate.setUserId(await Purchases.getAppUserID());

2. Paste the webhook URL

In your RevenueCat dashboard, go to Integrations → Webhooks and paste:

https://us-central1-appfiliate-5a18b.cloudfunctions.net/api/v1/webhooks/revenuecat

Start tracking React Native installs today

3 lines of code. Works with Expo and bare projects. Free plan included.