Deep Links and Adaptive Navigation
Deep Links
A deep link is a URL that opens your app on a specific screen, for example https://example.com/product/42 or myapp://product/42.
Step 1: Declare in Navigation
kotlin
@Serializable data class Product(val id: Int)
composable<Product>(
deepLinks = listOf(
navDeepLink<Product>(basePath = "https://example.com/product"),
navDeepLink<Product>(basePath = "myapp://product")
)
) { entry ->
val product: Product = entry.toRoute()
ProductScreen(product.id)
}
Step 2: Declare in the Manifest
xml
<activity android:name=".MainActivity" android:exported="true">
<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="https" android:host="example.com" android:pathPrefix="/product" />
</intent-filter>
<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" android:host="product" />
</intent-filter>
</activity>
App Links: Links with
autoVerify="true" and https become verified App Links that open your app directly, without a chooser. You must host a assetlinks.json file at https://example.com/.well-known/assetlinks.json that matches your app's package and signing certificate.
Step 3: Test with adb
bash
adb shell am start -W -a android.intent.action.VIEW -d "myapp://product/42" com.yourname.helloapp
Adaptive Navigation Suite
NavigationSuiteScaffold automatically shows a bottom bar on phones, a rail on medium screens and a drawer on large screens.
kotlin
@Composable
fun AdaptiveApp() {
var current by rememberSaveable { mutableStateOf(Destination.HOME) }
NavigationSuiteScaffold(
navigationSuiteItems = {
Destination.entries.forEach { dest ->
item(
selected = current == dest,
onClick = { current = dest },
icon = { Icon(dest.icon, contentDescription = dest.label) },
label = { Text(dest.label) }
)
}
}
) {
when (current) {
Destination.HOME -> HomeScreen()
Destination.SEARCH -> SearchScreen()
Destination.PROFILE -> ProfileScreen()
}
}
}
Security: Treat data from a deep link as untrusted input. Validate ids and never perform sensitive actions, like payments, directly from a link.
Conclusion
Deep links open specific screens from outside the app, and the navigation suite adapts the bar to the screen size.
Quick Summary: Declare deepLinks on destinations and in the manifest, verify App Links with assetlinks.json and use NavigationSuiteScaffold for adaptive navigation.

