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.
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.
<meta-data android:name="com.codeonair.APP_ID" android:value="proj_…" />
<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.
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);
}),
[],
);
// …
}What onLink gives you
| Field | Meaning |
|---|---|
path | The in-app path from the deep link URL, e.g. /product/42. |
params | Its query parameters, e.g. { ref: "share" }. |
deepLinkUrl | The full deep link URL set on the link. |
url | The short link that was opened, when known. |
isDeferred | True when the link was recovered after an install. |
isFirstSession | True on the first launch after install. |
matchMethod | install_referrer, clipboard, probabilistic, universal_link or uri_scheme. |
confidence | 1.0 for exact matches, lower for probabilistic ones. |
campaign | , utm, variant — the link's campaign, UTM tags and A/B variant. |
Native link setup#
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.
<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:
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:
{
"expo": {
"plugins": [["@codeonair/deeplink-react-native", {
"appId": "proj_…",
"domains": ["shop.codeonair.com"],
"scheme": "myapp"
}]]
}
}Create links from the app#
For share buttons and referrals — each user can get their own link.
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 });DeepLink.init() throws.