KNavHost
fun KNavHost(navController: NavHostController, startDestination: KDestination, modifier: Modifier = Modifier, builder: NavGraphBuilder.() -> Unit)(source)
Typed wrapper around Compose NavHost.
This variant accepts a typed KDestination as the start destination, avoiding raw route strings at call sites.
Example
@Composable
fun AppNavigation(navController: NavHostController) {
KNavHost(
navController = navController,
startDestination = Screen.Splash
) {
composable(Screen.Splash) {
SplashScreen(navController)
}
composable(Screen.Home) {
HomeScreen(navController)
}
}
}Content copied to clipboard
Parameters
navController
Controller managing the navigation state.
startDestination
Initial destination shown when the graph starts.
modifier
Optional host modifier.
builder
Navigation graph builder.