React Native setup

Install @invitebase/react-native, set up the Expo config plugin, and wire the provider and deep links

@invitebase/react-native wraps the native iOS and Android SDKs behind a hooks-first TypeScript API. Attribution runs natively on each platform — clipboard handoff on iOS, Play Install Referrer on Android — so a React Native app gets exactly the same attribution quality as a fully native one. Expo is supported first-class via a config plugin, with no ejecting.

This page covers installation and wiring. The hooks API is documented in the React Native hooks reference; the shared method surface in the SDK reference. For a guided first integration, see the React Native quickstart.

Install

npx expo install @invitebase/react-native

Add the config plugin to handle native module linking, the URL scheme, and Associated Domains / App Links in the managed workflow:

app.json
{
  "expo": {
    "plugins": [
      [
        "@invitebase/react-native",
        {
          "linkDomain": "mycompany.refr.link"
        }
      ]
    ]
  }
}

Then rebuild the dev client: npx expo prebuild && npx expo run:ios (or run:android).

In both cases, register your Apple Team ID + bundle ID and Android package name + signing fingerprints in the dashboard under Settings → Attribution — Invitebase serves the AASA and assetlinks.json files for your subdomain.

Provider setup

Wrap your app in InvitebaseProvider. It calls configure natively, starts deferred attribution, and makes the hooks work anywhere below it.

App.tsx
import { InvitebaseProvider } from '@invitebase/react-native';

export default function App() {
  return (
    <InvitebaseProvider publishableKey="pk_test_51Hq2jK">
      <RootNavigator />
    </InvitebaseProvider>
  );
}
PropTypeDescription
publishableKeystringRequired. pk_test_… or pk_live_… — the prefix determines test vs live mode.
autoResolvebooleanRun deferred attribution automatically on first launch. Default true.
debugbooleanLog SDK activity. Default false.

Deferred attribution (fresh installs) is fully automatic — the native layers run the clipboard handoff (iOS) and Install Referrer (Android) with no JavaScript involvement.

For the already-installed path (Universal Links / App Links), the provider listens for incoming URLs automatically on both Expo (expo-linking) and bare RN (Linking). If you manage URL subscriptions yourself — for example inside a navigation library's linking config — forward URLs explicitly:

import * as Linking from 'expo-linking';
import { useInvitebase } from '@invitebase/react-native';

function useInvitebaseLinks() {
  const invitebase = useInvitebase();

  React.useEffect(() => {
    const sub = Linking.addEventListener('url', ({ url }) => {
      invitebase.handleInbound(url);
    });
    Linking.getInitialURL().then((url) => url && invitebase.handleInbound(url));
    return () => sub.remove();
  }, [invitebase]);
}

handleInbound ignores URLs that are not referral links, so it is safe to forward everything.

Drop-in components

The package exports the cross-platform UI components as React Native components, themeable via your per-campaign configuration and fully replaceable with custom UI over the hooks:

import {
  InviteScreen,        // offer, link/code with copy, native share sheet, tier strip
  ReferrerStatusView,  // invitees, referral states, tier ladder, earnings
  CodeEntrySheet,      // manual entry with validation, strong/soft variants
} from '@invitebase/react-native';

Push notifications

If you use Invitebase-managed referral push notifications — the default delivery mode — forward the native device token — APNs on iOS, FCM on Android — after registering for remote notifications:

import * as Notifications from 'expo-notifications';
import { useInvitebase } from '@invitebase/react-native';

const invitebase = useInvitebase();

const { data: token } = await Notifications.getDevicePushTokenAsync();
await invitebase.setPushToken(token);

Any push library works as long as it exposes the native token (an Expo push token is not one). The SDK attaches the token to the current user and keeps it current across rotations. Details in setPushToken.

Bringing your own push provider instead? Skip this — device tokens stay on your side, and Invitebase will hand each notification to your backend as a notification.due webhook (bring-your-own-push is planned, not yet available).

What's next

On this page