How to create smart app links in React Native (open the app, or the right store)
, 5 min read
A "smart app link" in a React Native app should do two things:
- If the app is installed, open it on the right screen:
https://yourapp.com/product/42opensProductScreenwithid = 42. - If it isn't installed, send the person to the right store for their phone, not to a broken page.
React Native gives you everything for part 1 through the Linking API and React Navigation. Part 2 is a store-routing link. This guide wires both up in a React Native CLI app. (Using Expo? Most steps are simpler there. See the notes along the way.)
How the pieces fit together
Tap https://yourapp.com/product/42
│
├─ App installed? ── yes ──▶ iOS/Android opens the app ──▶ React Navigation → ProductScreen(42)
│
└─ no ──▶ yourapp.com/product/42 loads in the browser
└─▶ redirects to https://smartapplink.app/r/yourapp
├─ iPhone → App Store app
├─ Android → Play Store app
└─ Desktop → your website / QR page
The domain (yourapp.com) is yours, so the links never depend on a third party shutting down. That's exactly what bit everyone who used Firebase Dynamic Links.
Want the short way?
Smart App Link gives you one link that opens the App Store on iPhone and Google Play on Android. Free, no card.
Step 1: add a URL scheme (for testing and Android app-open)
A custom scheme like yourapp:// is the quickest way to test your routing. Add it to android/app/src/main/AndroidManifest.xml, inside the MainActivity <activity>:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="yourapp" />
</intent-filter>
On iOS, add it in Xcode: target → Info → URL Types → +. Our URL scheme guide has step-by-step instructions for Expo, React Native CLI, Flutter and native apps.
Step 2: add Universal Links (iOS) and App Links (Android)
A custom scheme alone isn't enough to share: yourapp:// does nothing for someone who doesn't have the app, and many apps won't make it tappable. Real links need to be https://.
Android: add a second intent filter with autoVerify:
<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="yourapp.com" android:pathPrefix="/product" />
</intent-filter>
Then host https://yourapp.com/.well-known/assetlinks.json with your package name and the SHA-256 of your Play app signing key.
iOS: in Xcode → Signing & Capabilities → + Capability → Associated Domains, add applinks:yourapp.com. Then host https://yourapp.com/.well-known/apple-app-site-association:
{
"applinks": {
"details": [
{ "appIDs": ["ABCDE12345.com.yourcompany.app"], "components": [{ "/": "/product/*" }] }
]
}
}
Then let React Native receive the link. In ios/YourApp/AppDelegate.swift, add these two methods to AppDelegate, with import React at the top:
func application(_ app: UIApplication, open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
return RCTLinkingManager.application(app, open: url, options: options)
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
return RCTLinkingManager.application(application, continue: userActivity,
restorationHandler: restorationHandler)
}
If your AppDelegate subclasses RCTAppDelegate (React Native 0.77 and 0.78), prefix both with override. On an Objective-C AppDelegate.mm, the equivalent is in the React Native Linking docs.
Expo: skip the native edits. Put "scheme": "yourapp", ios.associatedDomains and android.intentFilters in app.json, and Expo Router maps app/product/[id].tsx to /product/42 automatically.
Step 3: route links to screens with React Navigation
React Navigation reads the incoming URL and opens the matching screen for you. You don't need to call Linking.getInitialURL() yourself:
import { NavigationContainer, LinkingOptions } from "@react-navigation/native";
type RootStackParamList = {
Home: undefined;
Product: { id: string };
Invite: { code: string };
};
const linking: LinkingOptions<RootStackParamList> = {
prefixes: ["yourapp://", "https://yourapp.com"],
config: {
screens: {
Home: "",
Product: "product/:id",
Invite: "invite/:code",
},
},
};
export default function App() {
return (
<NavigationContainer linking={linking} fallback={<SplashScreen />}>
<RootStack />
</NavigationContainer>
);
}
ProductScreen now gets route.params.id === "42" for both yourapp://product/42 and https://yourapp.com/product/42, whether the app was cold-started by the link or already running.
Not using React Navigation? Handle both cases yourself:
import { useEffect } from "react";
import { Linking } from "react-native";
export function useDeepLinks(onUrl: (url: string) => void) {
useEffect(() => {
Linking.getInitialURL().then((url) => url && onUrl(url)); // cold start
const sub = Linking.addEventListener("url", ({ url }) => onUrl(url)); // app already open
return () => sub.remove();
}, [onUrl]);
}
Step 4: send non-users to the right store
When the app isn't installed, iOS and Android just open https://yourapp.com/product/42 in the browser. Make that page redirect to a smart link, which picks the store by device:
<!doctype html>
<meta charset="utf-8">
<title>Open in YourApp</title>
<meta http-equiv="refresh" content="0; url=https://smartapplink.app/r/yourapp?utm_source=product_link">
<a href="https://smartapplink.app/r/yourapp">Get YourApp</a>
To create the smart link, paste your App Store or Google Play URL into Smart App Link. It looks up the app and fills in the other store. On Android, you can also add your yourapp scheme to the link (Pro): people who already have the app go straight into it instead of the Play Store.
The utm_source tag shows how many people reach the store through deep-link fallbacks, compared with your bio, ads or share button.
Step 5: share the link from the app
Use React Native's built-in Share API. Share the https:// URL, never the custom scheme:
import { Platform, Share } from "react-native";
export async function shareProduct(id: string, name: string) {
const url = `https://yourapp.com/product/${id}`;
const message = `Check out ${name} on YourApp`;
await Share.share(
Platform.OS === "ios" ? { message, url } : { message: `${message} ${url}` } // Android ignores `url`
);
}
For a general "share this app" button with no specific screen, share the smart link itself. There's more on that in adding a share button in Expo and React Native.
Step 6: test every path
# Android: custom scheme and App Link
adb shell am start -W -a android.intent.action.VIEW -d "yourapp://product/42" com.yourcompany.app
adb shell am start -W -a android.intent.action.VIEW -d "https://yourapp.com/product/42"
# Android: is the domain verified? Look for "verified" next to yourapp.com
adb shell pm get-app-links com.yourcompany.app
# iOS simulator
xcrun simctl openurl booted "yourapp://product/42"
xcrun simctl openurl booted "https://yourapp.com/product/42"
On a real iPhone, put the https:// link in the Notes app and tap it. Typing it into Safari's address bar doesn't trigger Universal Links. Finally, uninstall the app and tap the same link: you should land in the App Store or Play Store.
Common problems
- App Link opens Chrome instead of the app.
assetlinks.jsonhas the upload key's fingerprint instead of the app signing key's, or the file is behind a redirect. - Universal Link works on the simulator but not on a device. Apple fetches the AASA file through its CDN and caches it. Check what Apple sees at
https://app-site-association.cdn-apple.com/a/v1/yourapp.com. - The link opens the app but the wrong screen. The path in your React Navigation
configdoesn't match the URL. Log the URL inuseDeepLinksto compare. - New users land on the home screen, not product 42. That's expected without deferred deep linking. See job C in our Firebase alternative guide.
Set up the store fallback in a minute. Create a free smart link. It's free for 3 links, with no card needed.