Deep linking with Expo Router: Universal Links, App Links and deferred links
In Expo Router every file is a screen with a URL, so most of deep linking is already done. What's left is the part this guide covers: how URLs map to files, rewriting links that don't match with +native-intent, a working Back button, links to screens behind sign-in, testing, and the link tapped before the app was installed.
In Expo Router every file in the app directory is a screen with a URL, so deep linking is on from the start: a link to /product/42 opens app/product/[id].tsx with id set to 42. What you still have to do is get the phone to hand links to your app (a custom scheme, or a verified https domain), rewrite URLs that don't match a file, make the Back button work after a link, and decide what happens to a link tapped before the app was installed.
This post is about the router side. The native set-up for Universal Links and App Links (the association files, app.json, EAS builds) is covered step by step in Expo deep linking: Universal Links and App Links.
How Expo Router maps a URL to a screen
| File | URL | Notes |
|---|---|---|
app/index.tsx |
/ |
index is the default route of its directory |
app/settings.tsx |
/settings |
|
app/product/[id].tsx |
/product/42 |
id is "42" |
app/(tabs)/orders.tsx |
/orders |
A directory in parentheses is a group and isn't part of the URL |
app/+not-found.tsx |
Anything else | Shown when no route matches |
Newer Expo templates keep the directory at src/app. The rules are the same.
The router matches the path. It doesn't check the host, so myapp://product/42 and https://links.example.com/product/42 reach the same screen. Expo's documentation says: "Expo Router does not require additional configuration for Universal Links and multiple domains. All URLs provided to your App will be evaluated."
That makes route design simple: use the same paths in the app as on your website, and a shared link works in both.
Step 1: get links to the app
Two kinds of link can open the app.
A custom scheme. Set it in the app config:
{
"expo": {
"scheme": "myapp"
}
}
After a rebuild, myapp://product/42 opens the app. Schemes are fine for testing and for links between your own apps. They do nothing when the app isn't installed.
An https domain. Add the domain for both platforms:
{
"expo": {
"ios": {
"bundleIdentifier": "com.example.app",
"associatedDomains": ["applinks:links.example.com"]
},
"android": {
"package": "com.example.app",
"intentFilters": [
{
"action": "VIEW",
"autoVerify": true,
"data": [{ "scheme": "https", "host": "links.example.com" }],
"category": ["BROWSABLE", "DEFAULT"]
}
]
}
}
}
The domain also has to serve apple-app-site-association and assetlinks.json. Both config changes are native, so they need a new build; an over-the-air update can't add a domain. Check the two files with the validator before you build.
Step 2: read the parameters
Path parameters and query parameters arrive through the same hook:
// app/product/[id].tsx
import { Text } from "react-native";
import { useLocalSearchParams } from "expo-router";
export default function Product() {
const { id, ref } = useLocalSearchParams<{ id: string; ref?: string }>();
return <Text>Product {id}</Text>;
}
For https://links.example.com/product/42?ref=email, id is "42" and ref is "email". Every value is a string. Treat them as outside input: check that the ID exists before you load anything, and don't let a link trigger a purchase or a deletion without the person confirming.
Use useLocalSearchParams in screens. useGlobalSearchParams returns the parameters of whichever route is active, so a screen lower in the stack re-renders when the URL above it changes.
Step 3: rewrite links that don't match, with +native-intent
Some incoming URLs don't have a matching file: paths from an older version of the app, a marketing URL such as /p/42, or a short link from a link service. Expo Router lets you rewrite them before it routes. Create +native-intent.tsx at the top of the app directory:
// app/+native-intent.tsx
export function redirectSystemPath({ path, initial }: { path: string; initial: boolean }) {
try {
const url = new URL(path, "myapp://app");
// Old marketing URL: /p/42 -> /product/42
if (url.pathname.startsWith("/p/")) {
return `/product/${url.pathname.slice(3)}${url.search}`;
}
return path;
} catch {
return "/unexpected-error";
}
}
Four things from Expo's documentation to keep in mind:
pathmay not be a path. The docs warn: "While the parameter is calledpaththere is no guarantee that this is a path or a valid URL". Parse it defensively, as above.- Don't throw. The docs say "Do not crash inside this function!" and suggest returning a route that shows an error screen. Hence the
try/catch. - It runs outside your app. The function is processed before your components exist, so it can't read auth state, context or the current route. It may return a promise if it needs to look something up.
- It's native only. On the web, handle rewrites with server redirects or in a layout.
initial is true when the link started the app and false when the app was already open.
For a rule that depends on app state, use a layout. While the app is open you can read usePathname() in a _layout file and render <Redirect href="…" /> when the path shouldn't be shown.
Step 4: make Back work after a deep link
A link that starts the app at /product/42 puts one screen on the stack. There's nothing under it, so the person can't go back to your home screen. Set an anchor in the layout:
// app/_layout.tsx
import { Stack } from "expo-router";
export const unstable_settings = {
// Any route can go back to `/`
anchor: "index",
};
export default function Layout() {
return <Stack />;
}
Now a deep link loads index first and the target on top of it. Some details:
- The setting used to be called
initialRouteName. Expo's docs mark that name as deprecated in favour ofanchor. - The anchor applies when the app is opened by a deep link. For navigation inside the app, ask for it:
<Link href="/route" withAnchor />orrouter.push("/route", { withAnchor: true }). - In tabs and drawers, Back returns to the anchor only when
backBehaviorisinitialRoute. - It doesn't work with async routes.
Step 5: links to screens behind sign-in
A deep link can arrive when nobody is signed in. Guard the private screens in the layout:
// app/_layout.tsx
import { Stack } from "expo-router";
import { useSession } from "../ctx";
export default function RootLayout() {
const { session } = useSession();
return (
<Stack>
<Stack.Protected guard={!!session}>
<Stack.Screen name="(app)" />
</Stack.Protected>
<Stack.Protected guard={!session}>
<Stack.Screen name="sign-in" />
</Stack.Protected>
</Stack>
);
}
When a link targets a screen whose guard is false, the router sends the person to the anchor route or the first screen that is available, which here is sign-in. Expo's authentication guide puts it this way: "If a user visits a deep link to any routes with the authentication check, they'll be redirected to the sign-in screen."
Two things to add yourself:
- Wait for the session. Reading a stored token is asynchronous. Keep the splash screen up with
SplashScreen.preventAutoHideAsync()until you know whether there's a session, then hide it. If you don't, a signed-in person who taps a link sees the sign-in screen flash, or lands on it. - Keep the destination. After sign-in the router shows the default screen, not the screen the link was for. If you want to continue to the link, store the path when it arrives (in memory is enough) and navigate to it once the session exists. Test this on both platforms with the app closed and open.
Stack.Protected is the current approach. Expo keeps the older redirect-based pattern in a separate guide for SDK 52 and earlier.
Step 6: handle links that match nothing
A mistyped or outdated link shouldn't show a blank screen. Add a +not-found.tsx file:
// app/+not-found.tsx
import { Unmatched } from "expo-router";
export default Unmatched;
Unmatched is the router's built-in screen. Most apps replace it with their own component and a button back to the home screen.
Step 7: test it
Use a development build. Expo Go can open your routes through its own exp:// URLs, but your scheme and your domain are compiled into the native app, so they need your own build.
# Custom scheme
npx uri-scheme open "myapp://product/42" --ios
npx uri-scheme open "myapp://product/42" --android
# https link
xcrun simctl openurl booted "https://links.example.com/product/42"
adb shell am start -W -a android.intent.action.VIEW \
-c android.intent.category.BROWSABLE \
-d "https://links.example.com/product/42"
Run each link in three states: app closed, app in the background, and app open on another screen. Then tap the link from a notes app on a real phone, because the simulator can't check everything. If the link opens the browser on Android, see Expo deep linking not working on Android. The general commands are in how to test deep links on Android and iOS.
Deferred links: when the app isn't installed yet
Everything above needs the app on the phone. A person who taps your link without it goes to the store, and after the install the app opens on its first screen: the link is gone. Carrying it through the install is called deferred deep linking, and Expo Router doesn't do it, because it needs a server that remembers the click.
CodeOnAir AppLinks does that part. The SDK has an Expo config plugin that writes the associated domain, the intent filter and the scheme for you:
npx expo install @codeonair/deeplink-react-native @react-native-async-storage/async-storage
npx expo install react-native-play-install-referrer
{
"expo": {
"plugins": [
["@codeonair/deeplink-react-native", {
"appId": "proj_…",
"domains": ["yourapp.codeonair.com"],
"scheme": "myapp"
}]
]
}
}
// app/_layout.tsx
import { useEffect } from "react";
import { Stack, router } from "expo-router";
import DeepLink from "@codeonair/deeplink-react-native";
DeepLink.init();
export default function RootLayout() {
useEffect(
() =>
DeepLink.onLink((link) => {
router.push({ pathname: link.path, params: link.params });
}),
[],
);
return <Stack />;
}
onLink fires for a link that opens a running app, a link that starts it, and the link from before the install, with link.isDeferred set to true.
One router detail: a short link such as yourapp.codeonair.com/summer-sale carries a slug, not one of your routes. Add a rule to +native-intent.tsx that returns / for URLs on your link domain, and let onLink navigate to link.path. Otherwise Expo Router looks for a route called summer-sale and shows the not-found screen. The full set-up is in the React Native and Expo SDK docs.
FAQ
Does Expo Router support deep linking out of the box?
Yes. Every route has a URL and the router evaluates every URL the app receives. You add a scheme or a verified domain so the phone sends links to the app.
What is +native-intent.tsx used for?
It exports redirectSystemPath, which receives each incoming native link before routing and returns the path to open. Use it to map old URLs, marketing URLs and third-party links to your routes.
Why is there no Back button after a deep link opens my app?
The stack holds only the linked screen. Export unstable_settings with an anchor from the layout so the anchor route is loaded underneath.
How do I deep link to a screen that needs sign-in?
Wrap the private screens in Stack.Protected. A signed-out person is redirected to the sign-in screen. To continue to the link afterwards, keep the path and navigate to it when the session exists.
Do Universal Links work in Expo Go?
Not for your own domain. Associated Domains and intent filters are part of the native build, so use a development build.
Try it with a link domain
CodeOnAir gives your app a link domain, hosts both association files for it, and returns the link after an install through one callback. You can create a free account: the Free plan includes 100 app links and 10,000 clicks a month.
Checked on 16 November 2026 against Expo's documentation on Expo Router notation, native intent, router settings, protected routes, authentication and linking.