Skip to content
CodeOnAir
Docs menu

React Native SDK Setup

Install the CodeOnAir deep link SDK in a React Native or Expo app: App ID, onLink handler, Universal Links, App Links and in-app link creation.

@codeonair/deeplink-react-native handles links that open your app, recovers the link after an install, and creates links from inside the app. It needs only your App ID.

Install#

The SDK is on npm as @codeonair/deeplink-react-native (currently 1.0.0). It needs AsyncStorage; the Play Install Referrer package is optional and gives exact Android install matching.

Terminal
npm install @codeonair/deeplink-react-native @react-native-async-storage/async-storage
npm install react-native-play-install-referrer   # exact Android install attribution
cd ios && pod install

Add your App ID#

Copy it from Settings → App credentials. The SDK reads it from the native config, so your JavaScript never holds a key.

android/app/src/main/AndroidManifest.xml — inside <application>
<meta-data android:name="com.codeonair.APP_ID" android:value="proj_…" />
ios/<App>/Info.plist
<key>CodeOnAirAppId</key>
<string>proj_…</string>

Initialize and listen#

Call DeepLink.init() once, outside your components, and subscribe with onLink. It fires for links that open a running app, links that start it, and the deferred link on the first launch after install.

App.tsx
import { useEffect } from "react";
import DeepLink from "@codeonair/deeplink-react-native";

DeepLink.init(); // reads the App ID from AndroidManifest.xml / Info.plist

export default function App() {
  useEffect(
    () =>
      DeepLink.onLink((link) => {
        // link.path, link.params, link.isDeferred, link.campaign …
        navigation.navigate(link.path, link.params);
      }),
    [],
  );
  // …
}
FieldMeaning
pathThe in-app path from the deep link URL, e.g. /product/42.
paramsIts query parameters, e.g. { ref: "share" }.
deepLinkUrlThe full deep link URL set on the link.
urlThe short link that was opened, when known.
isDeferredTrue when the link was recovered after an install.
isFirstSessionTrue on the first launch after install.
matchMethodinstall_referrer, clipboard, probabilistic, universal_link or uri_scheme.
confidence1.0 for exact matches, lower for probabilistic ones.
campaign, utm, variant — the link's campaign, UTM tags and A/B variant.

iOS

Xcode → your target → Signing & Capabilities → + Associated Domains → add applinks:shop.codeonair.com (one line per link domain). If you set a URI scheme, add it under Info → URL Types.

Android

Your main activity should have android:launchMode="singleTask" (React Native's template does), so a link reuses the running app.

android/app/src/main/AndroidManifest.xml — inside your main <activity>
<intent-filter android:autoVerify="true">
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <data android:scheme="https" android:host="shop.codeonair.com" />
</intent-filter>

The 📱 App setup box on the AppLinks page shows these lines with your own domains filled in.

Expo#

Install the same packages with Expo's installer, which picks versions that match your Expo SDK:

Terminal
npx expo install @codeonair/deeplink-react-native @react-native-async-storage/async-storage
npx expo install react-native-play-install-referrer   # exact Android install attribution

With a development build or prebuild, the config plugin adds the App ID, Associated Domains, the intent filter and your scheme:

app.json
{
  "expo": {
    "plugins": [["@codeonair/deeplink-react-native", {
      "appId": "proj_…",
      "domains": ["shop.codeonair.com"],
      "scheme": "myapp"
    }]]
  }
}
Important
Expo Go can't load native modules — use a development build to test links.

For share buttons and referrals — each user can get their own link.

Share a product
const url = await DeepLink.createLink({
  path: "/product/42",
  params: { ref: "share" },
  campaign: "in-app-share",
});
await Share.share({ message: url });

await DeepLink.trackEvent("purchase", { amount: 499 });
Note
Everything — deferred links, events and creating links — runs on the App ID in your native config. Without it DeepLink.init() throws.
Stuck? Write to support@codeonair.com with your App ID and what you tried — we reply within a working day.