Not every navigation starts with a tap inside the app. A route can send the user somewhere else the moment it opens, and a URL tapped in an email, a chat or another app can open a screen directly. Expo Router handles both with the routes you already have. It can also rewrite a native link before matching it, and it sends links meant for a browser or another app out of the app.
Key terms
- Redirect: a component exported by
expo-routerthat navigates to itshrefthe wayrouter.replacedoes and renders nothing. - scheme: the app config property that sets the custom URL scheme for links into your app, such as
shopapp. - deep link: a URL from outside the app that opens a specific page in it.
- +native-intent: a file at the top level of
src/appthat Expo Router loads to rewrite incoming native URLs. - redirectSystemPath: the function
+native-intentexports, which receives the incoming path and returns the path to open.
Redirect takes the place of its route
Return <Redirect href="..." /> from a page or a layout and Expo Router navigates to the href right away, without rendering the current page. It works like router.replace, so the redirecting route is replaced in the history rather than kept below the destination.
A common use returns a redirect from a screen when nobody is signed in:
tsxif (!session) { return <Redirect href="/sign-in" />; }
The BasketScreen example covers a renamed route. The screen moved to /cart, and src/app/basket.tsx now only returns <Redirect href="/cart" />, so old links to /basket still land on the cart, and back from the cart skips basket. Layout Screen components take no redirect prop, so a redirect lives in the route file like this one.
Every route is a deep link
Expo Router supports deep linking by default: any page that a Link can open can also be opened by a URL from outside the app. On the web, the deep link is the page's URL. On Android and iOS, the scheme in the app config becomes the prefix. With the scheme below, src/app/cart.tsx opens from shopapp://cart.
json{ "expo": { "scheme": "shopapp" } }
scheme accepts a string or an array of strings. It is a build-time setting with no effect in Expo Go, so after adding it you need a new development build, and once that is installed, shopapp:// links open the app. Without a custom scheme, the app still answers to its android.package and ios.bundleIdentifier, which Expo Prebuild adds as default schemes. The default template's app.json has the placeholder scheme helloworld, but create-expo-app replaces it with your project name in lowercase, without characters such as dashes, so npx create-expo-app shop-app starts with shopapp. Check scheme in app.json and change it if you want another one. With app links and universal links, an https URL can open the app as well.
To test, run npx uri-scheme open shopapp://cart --ios (or --android). In Expo Go during development, the app's URL looks like exp://127.0.0.1:8081, and /--/ separates the app's address from the deep link path: exp://127.0.0.1:8081/--/cart. Deep links into the app don't work on a device where it isn't installed. The linking guide's section on handling URLs with Linking.useLinkingURL() doesn't apply to an Expo Router app.
Rewriting native links before they match
Some URLs that reach the app don't match a route. Third-party referral links often look like <your-scheme>://<provider-hostname>/<uuid>, and older versions of the app may have shared URLs that no longer exist. For these, create +native-intent.tsx directly in src/app (.ts, .js and .jsx work too) and export redirectSystemPath.
It receives { path, initial } and returns a string, a Promise<string | null>, or null. initial is true for the URL that launched the app and false for URLs received while it runs, which Expo Router awaits. A falsy return means no redirection. For a URL that arrives while the app is open, Expo Router then doesn't navigate at all.
The function has limits:
- It is native only and does not run on the web. Web routing is resolved before the site's JavaScript runs, so use a server redirect or a client redirect in the root layout there.
- It runs outside your app's context, with no access to state such as whether the user is signed in or which route is showing.
pathis not guaranteed to be a path or even a valid URL.- Throwing inside it can crash the app. Wrap the code in
try/catch, use.catch()on promises, and return an error route instead.
The redirectSystemPath example sends a partner's referral links to /deals, returns every other path unchanged, and falls back to /link-error if parsing fails.
Links that leave the app
Write a Link href as a full http or https URL and it opens in the user's browser, as in <Link href="https://shopapp.example/help">. For URLs of websites or other apps, Expo Router calls openURL from expo-linking and returns without navigating inside the app. mailto: opens the mail app and tel: the phone app.
Full URLs such as https:, mailto: and tel: links open outside the app, and so does any URL with a scheme followed by //, such as otherapp://path. Relative hrefs never leave the app. On the web, the href attribute of the rendered <a> keeps an external URL as it is.
Code Examples
import { Redirect } from 'expo-router';
export default function BasketScreen() {
return <Redirect href="/cart" />;
}export function redirectSystemPath({
path,
}: {
path: string;
initial: boolean;
}): string {
try {
const url = new URL(path, 'shopapp://app');
if (url.hostname === 'referrals.partner.example') {
return '/deals';
}
return path;
} catch {
return '/link-error';
}
}