Deep Linking

Article · 2:00

Opening an exact screen from a URL, a notification or another app - and the file that proves you own the domain.

A deep link opens a specific screen rather than the home screen. With Expo Router you have most of it already, because every screen has a path: myapp://article/42 maps to app/article/[id].tsx with no routing table to maintain.

There are two kinds and the difference matters. A custom scheme - myapp:// - is simple, works immediately, and has a weakness: any app can claim any scheme, and if the app is not installed the link does nothing. Universal Links on iOS and App Links on Android use an ordinary https:// URL, so the same link opens the app when it is installed and the website when it is not. They require proving you control the domain, by serving a file: /.well-known/apple-app-site-association for iOS and /.well-known/assetlinks.json for Android. Both must be served over HTTPS as JSON, with no redirect.

Test both. npx uri-scheme open drives a scheme link into a simulator, and for universal links the only honest test is tapping a real link on a real device - iOS will not follow one typed into Safari's address bar, which has convinced many developers their setup is broken when it is not.

# app.json - declare the scheme and the domains you own.
{
  "expo": {
    "scheme": "myapp",
    "ios": {
      "associatedDomains": ["applinks:omniacad.com"]
    },
    "android": {
      "intentFilters": [
        {
          "action": "VIEW",
          "autoVerify": true,
          "data": [{ "scheme": "https", "host": "omniacad.com", "pathPrefix": "/article" }],
          "category": ["BROWSABLE", "DEFAULT"]
        }
      ]
    }
  }
}

# Served at https://omniacad.com/.well-known/apple-app-site-association
# as application/json, over HTTPS, with NO redirect and no .json extension.
{
  "applinks": {
    "details": [
      { "appID": "TEAMID.com.example.myapp", "paths": ["/article/*"] }
    ]
  }
}

# Served at https://omniacad.com/.well-known/assetlinks.json
[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.example.myapp",
    "sha256_cert_fingerprints": ["AA:BB:CC:..."]
  }
}]

# Testing a scheme link against a running simulator or emulator.
npx uri-scheme open "myapp://article/42" --ios
npx uri-scheme open "myapp://article/42" --android

# Universal links can only be tested by tapping a real link on a real
# device. Typing one into Safari's address bar deliberately does not work.