Deep links vs Universal Links and App Links
Tap a link in a chat and something opens: your app, the website, an error, or someone else's app. Watch who answers myapp:// and who answers https://, with and without the app, and with a copycat installed.
What you'll take away
- Tell myapp:// from a verified https link: what opens with the app, and without it
- Explain why a copycat can take a custom scheme, and why a sign-in code needs PKCE
- Serve apple-app-site-association and assetlinks.json so a domain vouches for the app
- Work out why an https link opens the site: no file, a redirect, a wrong fingerprint
The 1-minute version
Tap a point and the picture below plays that step.
Take the app off, then add a copycat, and see which way still takes the person to the right place
You send myapp://product/123 to a friend who hasn't installed the app. What happens when they tap it?
The picture: the big phone shows what you see, the chat with the link and then whatever opens. The building beside it is the phone's system, with its list of which app claimed which link; the tower is shop.example, with its verification file on the roof. A model of what Apple and Google document, not a real phone.
Compare them all: Links into the app
The same product link tapped on three phones: one with the app, one without, and one with a copycat that registered the same name. See where each way takes the person.
Use it when Links between your own apps on a phone, or while developing
Skip it when Links you share, or links carrying anything that matters (a sign-in code): no web fallback, and another app can take it
A model of what Apple and Google document (Android 12 and up). The verification files in the code below were checked for their shape, but there's no real phone here to tap. Press any tile to see it large above, with when it fits.
What each side needs
| iOS: Universal Links | Android: App Links | |
|---|---|---|
| the site serves | /.well-known/apple-app-site-association | /.well-known/assetlinks.json |
| it names | TEAMID.bundle.id, and the paths | the package, and the signing certificate's SHA-256 |
| the app declares | Associated Domains: applinks:shop.example | an https intent filter with autoVerify |
| if it doesn't verify | the link opens Safari | the browser (Android 12 and up) |
A link is input from outside
Anyone can type anything after product/. Check every value a link brings before using it, and never let a link pay, delete or sign anything without asking the person first.
Sign-in codes and custom schemes
When a sign-in comes back to the app through myapp://, another app that registered the same scheme can catch the code. RFC 8252, OAuth for native apps, has public apps always use PKCE, so a caught code is useless without the verifier; a verified https redirect is better still.
In real code
// React Navigation: both kinds of link land on the same screens, myapp:// and the verified https domain.
import type { LinkingOptions } from "@react-navigation/native";
export type RootParams = { Home: undefined; Product: { id: number }; NotFound: undefined };
// A link is input from outside: anyone can type anything after product/. Check it before using it.
export function productId(raw: unknown): number | null {
const s = String(raw);
return /^[1-9]\d{0,8}$/.test(s) ? Number(s) : null;
}
export const linking: LinkingOptions<RootParams> = {
prefixes: ["myapp://", "https://shop.example"],
config: {
screens: {
Home: "",
// 0 = no such product: the screen shows "not found" instead of trusting the link.
Product: { path: "product/:id", parse: { id: (raw: string) => productId(raw) ?? 0 } },
NotFound: "*",
},
},
};
tsc against each library's own published types (react-native and the libraries this file imports); type-checked only, never run on a phoneReact Navigation maps both prefixes to the same screens, and the product id from the link is checked before anything uses it. Type-checked against the library's own types.
Common questions
What's the difference between a deep link, a Universal Link and an App Link?
A deep link is any link that takes you to a screen inside the app, whether it's a custom scheme (myapp://) or https. A Universal Link is an https link iOS opens in your app because the domain vouches for it; an App Link is the same thing on Android.
Why does my https link open the website instead of the app?
Usually because verification failed: no file at /.well-known/, a file behind a redirect, a team ID or fingerprint that doesn't match the app as it's really signed, or the app missing Associated Domains / autoVerify. Since Android 12, links that don't verify open in the browser.
Should I still use a custom scheme?
It's fine for links between your own apps on a phone, or while developing. For links you share with people, use verified https: it opens the website when the app isn't there, and no other app can take it.
Can a custom scheme really be hijacked?
Yes. Nobody owns myapp://; any app can claim it. Apple says itself that when several apps register the same scheme, there's no process that decides which one gets it; Android asks the user. It matters most when the link carries a sign-in code: always use PKCE.
How do I serve apple-app-site-association and assetlinks.json?
At the domain's /.well-known/, over https, answered as plain JSON with no redirect. Apple's file has no extension. Android's lists the SHA-256 fingerprint of the key that really signs the app; with Play App Signing, take it from the Play Console.
Can I trust what comes in with a link?
No. The path and the query come from outside, and anyone can type anything into a link. Check values before using them (an id must be a number), and never let a link act for the user without asking.
Next lesson
Tokens on a phoneLevel: Deep
A sign-in code must land in your app and nowhere else; next, the tokens it buys: where they live and how they refresh.