Complete guide to implementing deep links and universal links in Capacitor apps. Covers iOS Universal Links, Android App Links, custom URL schemes, and navigation handling. Use this skill when users need to open their app from links.
npx playbooks add skill cap-go/capacitor-skills --skill capacitor-deep-linking
Route custom-scheme links, iOS Universal Links, and Android App Links into the web app.
TRIGGER when:
myapp:// schemes, Universal Links, or App Links to a Capacitor appappUrlOpen fires on warm open but the URL is missing on cold launch (or the reverse)SceneDelegate.swiftadb shell pm get-app-links shows none or 1024 instead of verifiedDo not use:
capacitor-uiscene-migrationcapacitor-push-notificationsios-android-logscapacitor-plugins| Type | Platform | Format | Needs hosted file | Verified ownership |
|------|----------|--------|-------------------|--------------------|
| Custom scheme | both | myapp://product/123 | no | no (any app can claim it) |
| Universal Links | iOS | https://example.com/product/123 | /.well-known/apple-app-site-association | yes |
| App Links | Android 6+ | https://example.com/product/123 | /.well-known/assetlinks.json | yes |
Prefer verified https links for anything security-sensitive (OAuth, magic links). Custom schemes can be hijacked by another app.
capacitor.config., ios/App/App/Info.plist, ios/App/App/.entitlements, ios/App/App/AppDelegate.swift, ios/App/App/SceneDelegate.swift (if present), android/app/src/main/AndroidManifest.xml, and the @capacitor/app version in package.json.UIApplicationSceneManifest present in Info.plist (Capacitor 8.5+ template or migrated app) -> URL events arrive in SceneDelegate. Any custom code in AppDelegate application(_:open:options:) or application(_:continue:restorationHandler:) is dead code. See [references/ios-scene-delegate.md](references/ios-scene-delegate.md).capacitor-uiscene-migration.@capacitor/app (npm install @capacitor/app && npx cap sync).appUrlOpen and getLaunchUrl(). See below.CFBundleURLTypes, Android <intent-filter>), then verified links per platform:Only load a reference when its topic is in play.
import { App, type URLOpenListenerEvent } from '@capacitor/app';
let lastHandled: string | undefined;
function route(rawUrl: string) {
if (rawUrl === lastHandled) return; // cold start can deliver the same URL to both paths
lastHandled = rawUrl;
const url = new URL(rawUrl);
// myapp://product/123 -> host "product", pathname "/123"
// https://example.com/product/123 -> pathname "/product/123"
const path = url.protocol.startsWith('http')
? url.pathname
: `/${url.host}${url.pathname}`;
router.navigate(path + url.search); // your router
}
export async function initDeepLinks() {
await App.addListener('appUrlOpen', (event: URLOpenListenerEvent) => route(event.url));
const launch = await App.getLaunchUrl(); // resolves undefined or { url }
if (launch?.url) route(launch.url);
}
Traps:
host, not pathname. Normalize both forms as above.getLaunchUrl() is the fallback for cold start.NgZone.run) or navigation silently does nothing.getLaunchUrl() and appUrlOpen.iOS ios/App/App/Info.plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.example.app</string>
<key>CFBundleURLSchemes</key>
<array><string>myapp</string></array>
</dict>
</array>
Android AndroidManifest.xml, inside the existing MainActivity (keep the template's android:launchMode="singleTask" so warm opens reuse the 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="myapp" />
</intent-filter>
Run every row on a physical device (Universal Links do not work reliably from the Simulator address bar; tap from Notes/Messages instead).
| Scenario | iOS | Android |
|----------|-----|---------|
| Custom scheme, warm | xcrun simctl openurl booted "myapp://product/123" | adb shell am start -W -a android.intent.action.VIEW -d "myapp://product/123" com.example.app |
| Custom scheme, cold | kill app, then same command | adb shell am force-stop com.example.app, then same command |
| Verified link, warm | tap https://example.com/product/123 in Notes | adb shell am start -W -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://example.com/product/123" |
| Verified link, cold | swipe app away, tap link | force-stop, then same command |
| Ownership check | curl -sI https://example.com/.well-known/apple-app-site-association (200, no redirect) | adb shell pm get-app-links com.example.app shows verified |
Pass criteria: each case lands on the right route, appUrlOpen logs once, and on cold start getLaunchUrl() returns the URL. After a Capacitor 8.5 scene migration, re-run the full matrix: cold launch takes a different native path (scene(_:willConnectTo:options:)) than warm open (scene(_:openURLContexts:) / scene(_:continue:)).
Grep for dead handlers after migration:
grep -n "open url: URL\|continue userActivity" ios/App/App/AppDelegate.swift
grep -n "SceneDelegateProxy" ios/App/App/SceneDelegate.swift
| Symptom / message | Cause | Fix |
|-------------------|-------|-----|
| Link opens in Safari, app installed | AASA not fetched, wrong appID, entitlement missing, or user long-pressed and chose "Open in Safari" | Check AASA via Apple CDN, TEAMID.bundleId, applinks: entitlement; long-press link and choose "Open in App" to reset |
| Custom AppDelegate URL code stopped running after 8.5 update | Scene manifest exists; iOS calls SceneDelegate instead | Move logic to SceneDelegate (reference: ios-scene-delegate) |
| Warm opens work, cold launch lands on home | Listener registered late, or custom SceneDelegate code ignores connectionOptions | Call getLaunchUrl() at bootstrap; keep SceneDelegateProxy.shared.scene(_:willConnectTo:options:) |
| Safari cannot open the page because the address is invalid | Custom scheme not registered in installed build | Add CFBundleURLTypes, rebuild (not just cap sync) |
| Error: Activity not started, unable to resolve Intent | No intent-filter matches scheme/host | Fix <data> entries; reinstall app |
| pm get-app-links shows 1024 or none | assetlinks.json unreachable, wrong package, or wrong SHA-256 (often the Play App Signing key) | Fix file, then adb shell pm verify-app-links --re-verify com.example.app |
| Android shows app chooser for https link | Domain not verified (autoVerify missing or failed) | Add android:autoVerify="true", re-verify |
| OAuth redirect returns to browser tab, not app | Redirect URI does not match registered scheme / verified domain | Register exact redirect URI; prefer verified https link |
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.