A deep link opens your app on a specific screen instead of the home screen. Flutter’s docs put it simply: deep links “not only open an app, but also take the user to a specific location ‘deep’ inside the app.” You need them for password reset emails, shared content, marketing campaigns and push notifications.
With go_router, the Dart side is mostly done once your routes are defined. The work is on the platform side: an entitlement on iOS, an intent filter on Android, and two small files on your website. This guide walks through all of it. It is part of our guide to building a Flutter app with Claude Code.
How the pieces fit
- A user taps
https://example.com/product/42. - iOS or Android checks that your app is allowed to open links for
example.com, using a file hosted on that domain. - The OS opens your app and passes the URL to Flutter.
- go_router matches
/product/42and shows that screen. In go_router’s words: “When a deep link is received from the platform, GoRouter will display the configured screen based on the URL path.”
Step 1: define the routes
Path parameters use a : prefix and are read from state.pathParameters. Query parameters come from state.uri.queryParameters.
final router = GoRouter(
routes: [
GoRoute(
path: '/',
builder: (context, state) => const HomeScreen(),
routes: [
GoRoute(
path: 'product/:id',
builder: (context, state) =>
ProductScreen(id: state.pathParameters['id']!),
),
],
),
GoRoute(
path: '/search',
builder: (context, state) =>
SearchScreen(query: state.uri.queryParameters['q']),
),
],
);
void main() => runApp(MaterialApp.router(routerConfig: router));
Design your paths like a public API. Once links are in emails and social posts, renaming a route breaks them.
Step 2: protect routes with a redirect
A deep link can land a signed-out user on a screen that needs an account. go_router’s redirect handles this. A top-level redirect on GoRouter runs before every navigation event, and returning null means “show the route as requested.”
redirect: (context, state) {
final signedIn = authState.isSignedIn;
final goingToLogin = state.uri.path == '/login';
if (!signedIn && !goingToLogin) {
return '/login?from=${Uri.encodeComponent(state.uri.toString())}';
}
return null;
},
After sign-in, read from and send the user to where they were going. go_router caps chained redirects with redirectLimit, which defaults to 5, and shows the error screen if the limit is exceeded.
Step 3: iOS universal links
Info.plist flag. On Flutter 3.27 and later, the built-in deep link handler works without a flag. On earlier versions, add FlutterDeepLinkingEnabled set to YES. If you use a third-party plugin such as app_links, set it to NO, because Flutter’s handler otherwise breaks those plugins.
Associated Domains. In Xcode, open ios/Runner.xcworkspace, select the Runner target, then Signing & Capabilities, + Capability, Associated Domains. Add applinks:example.com. The resulting Runner.entitlements contains:
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:example.com</string>
</array>
Note Flutter’s warning: “Personal development teams don’t support the Associated Domains capability.” You need a paid Apple Developer account.
The AASA file. Create a file named apple-app-site-association with no .json extension. The app ID is your Team ID, a dot, then your bundle ID:
{
"applinks": {
"details": [
{
"appIDs": ["TEAMID1234.com.example.myapp"],
"components": [{ "/": "/product/*" }, { "/": "/search" }]
}
]
}
}
Host it at https://example.com/.well-known/apple-app-site-association. If you use flavors with different bundle IDs, list each one in appIDs. Our Flutter flavors for dev and prod post covers that setup.
Step 4: Android app links
In android/app/src/main/AndroidManifest.xml, inside the .MainActivity activity, add an intent filter with autoVerify:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="example.com" />
<data android:scheme="https" />
</intent-filter>
On Flutter versions earlier than 3.27, also add <meta-data android:name="flutter_deeplinking_enabled" android:value="true" />. As on iOS, set it to false if you use a third-party deep link plugin.
The assetlinks.json file. Host it at https://example.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:..."]
}
}]
The fingerprint must match the key that signs the installed app. If you use Play App Signing, copy it from Play Console under Release, Setup, App Integrity, App Signing. For a local keystore, run keytool -list -v -keystore <path-to-keystore>. This is the most common failure: the debug build works, the Play build does not, because the Play signing key’s fingerprint is missing. Add one entry per key you use.
Step 5: test
iOS Simulator:
xcrun simctl openurl booted https://example.com/product/42
On a real device, type the URL into the Notes app and tap it. Flutter’s docs warn that “It can take up to 24 hours before Apple’s CDN requests the AASA file from your domain,” so a fresh setup may not work at once.
Android:
adb shell 'am start -a android.intent.action.VIEW \
-c android.intent.category.BROWSABLE \
-d "https://example.com/product/42"' \
com.example.myapp
This only tests the app side. Flutter notes the command launches the app “even if assetlinks.json is missing.” To test verification, tap a real link in another app, such as a document or chat. During local debugging you may need to turn on “Supported web addresses” for the app in Android settings.
Common mistakes
- AASA served with a
.jsonextension or behind a redirect. Serve it at the exact path. - Wrong Team ID or bundle ID in
appIDs. - Missing release fingerprint in
assetlinks.json. - Routes that need data before it loads. Show a loading state on the deep-linked screen instead of assuming the home screen ran first.
- Two handlers fighting. If you add
app_linksor a similar plugin, turn off Flutter’s built-in handler on both platforms.
Deep links also power notification taps. When you add them, see Flutter push notifications with Firebase and Flutter local notifications. If you use Supabase or Firebase auth with email links, the same routes handle the callback; see Flutter Supabase Google auth for a related flow.
MobileKit’s build skills include this setup as a checklist, which helps because most deep link bugs are a missing file or fingerprint, not Dart code.
Sources read on the day this post was written: Flutter: deep linking, Flutter: set up universal links for iOS, Flutter: set up app links for Android, go_router: deep linking, go_router: configuration and go_router: redirection.