Composable Function

NavHost

Provides a place in the Compose hierarchy for self contained navigation to occur.

RevenueCat

RevenueCat

Add subscriptions to your apps in minutes

Ad Get started for free
Common
Deprecated Deprecated in favor of NavHost that supports AnimatedContent
@Composable
public fun NavHost(
    navController: NavHostController,
    startDestination: String,
    modifier: Modifier = Modifier,
    route: String? = null,
    builder: NavGraphBuilder.() -> Unit,
)

Provides a place in the Compose hierarchy for self contained navigation to occur.

Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.

The builder passed into this method is remembered. This means that for this NavHost, the contents of the builder cannot be changed.

Parameters

navController the navController for this host
startDestination the route for the start destination
modifier The modifier to be applied to the layout.
route the route for the graph
builder the builder used to construct the graph
Common
Deprecated Deprecated in favor of NavHost that supports sizeTransform

@Composable
public fun NavHost(
    navController: NavHostController,
    startDestination: String,
    modifier: Modifier = Modifier,
    contentAlignment: Alignment = Alignment.TopStart,
    route: String? = null,
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        DefaultNavTransitions.enterTransition,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        DefaultNavTransitions.exitTransition,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        enterTransition,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        exitTransition,
    builder: NavGraphBuilder.() -> Unit,
)

Provides a place in the Compose hierarchy for self contained navigation to occur.

Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.

The builder passed into this method is remembered. This means that for this NavHost, the contents of the builder cannot be changed.

Parameters

navController the navController for this host
startDestination the route for the start destination
modifier The modifier to be applied to the layout.
contentAlignment The Alignment of the AnimatedContent
route the route for the graph
enterTransition callback to define enter transitions for destination in this host
exitTransition callback to define exit transitions for destination in this host
popEnterTransition callback to define popEnter transitions for destination in this host
popExitTransition callback to define popExit transitions for destination in this host
builder the builder used to construct the graph
Common
Deprecated Deprecated in favor of NavHost that supports predictivePopEnterTransition and predictivePopExitTransition

@Composable
public fun NavHost(
    navController: NavHostController,
    startDestination: String,
    modifier: Modifier = Modifier,
    contentAlignment: Alignment = Alignment.TopStart,
    route: String? = null,
    enterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        DefaultNavTransitions.enterTransition,
    exitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        DefaultNavTransitions.exitTransition,
    popEnterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        enterTransition,
    popExitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        exitTransition,
    sizeTransform:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
        DefaultNavTransitions.sizeTransform,
    builder: NavGraphBuilder.() -> Unit,
)

Provides a place in the Compose hierarchy for self contained navigation to occur.

Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.

The builder passed into this method is remembered. This means that for this NavHost, the contents of the builder cannot be changed.

Parameters

navController the navController for this host
startDestination the route for the start destination
modifier The modifier to be applied to the layout.
contentAlignment The Alignment of the AnimatedContent
route the route for the graph
enterTransition callback to define enter transitions for destination in this host
exitTransition callback to define exit transitions for destination in this host
popEnterTransition callback to define popEnter transitions for destination in this host
popExitTransition callback to define popExit transitions for destination in this host
sizeTransform callback to define the size transform for destinations in this host
builder the builder used to construct the graph

Common
@Composable
public fun NavHost(
    navController: NavHostController,
    startDestination: String,
    modifier: Modifier = Modifier,
    contentAlignment: Alignment = Alignment.TopStart,
    route: String? = null,
    enterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        DefaultNavTransitions.enterTransition,
    exitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        DefaultNavTransitions.exitTransition,
    popEnterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        enterTransition,
    popExitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        exitTransition,
    predictivePopEnterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> EnterTransition) =
        DefaultNavTransitions.predictivePopEnterTransition,
    predictivePopExitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> ExitTransition) =
        DefaultNavTransitions.predictivePopExitTransition,
    sizeTransform:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
        DefaultNavTransitions.sizeTransform,
    builder: NavGraphBuilder.() -> Unit,
)

Provides a place in the Compose hierarchy for self contained navigation to occur.

Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.

The builder passed into this method is remembered. This means that for this NavHost, the contents of the builder cannot be changed.

Parameters

navController the navController for this host
startDestination the route for the start destination
modifier The modifier to be applied to the layout.
contentAlignment The Alignment of the AnimatedContent
route the route for the graph
enterTransition callback to define enter transitions for destination in this host
exitTransition callback to define exit transitions for destination in this host
popEnterTransition callback to define popEnter transitions for destination in this host
popExitTransition callback to define popExit transitions for destination in this host
predictivePopEnterTransition callback to define predictivePopEnter transitions for destination in this host
predictivePopExitTransition callback to define predictivePopExit transitions for destination in this host
sizeTransform callback to define the size transform for destinations in this host
builder the builder used to construct the graph
Common
Deprecated Deprecated in favor of NavHost that supports predictivePopEnterTransition and predictivePopExitTransition

@Composable
public fun NavHost(
    navController: NavHostController,
    startDestination: KClass<*>,
    modifier: Modifier = Modifier,
    contentAlignment: Alignment = Alignment.TopStart,
    route: KClass<*>? = null,
    typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
    enterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        DefaultNavTransitions.enterTransition,
    exitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        DefaultNavTransitions.exitTransition,
    popEnterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        enterTransition,
    popExitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        exitTransition,
    sizeTransform:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
        DefaultNavTransitions.sizeTransform,
    builder: NavGraphBuilder.() -> Unit,
)

Provides a place in the Compose hierarchy for self contained navigation to occur.

Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.

The builder passed into this method is remembered. This means that for this NavHost, the contents of the builder cannot be changed.

Parameters

navController the navController for this host
startDestination the route from a KClass for the start destination
modifier The modifier to be applied to the layout.
contentAlignment The Alignment of the AnimatedContent
route the route from a KClass for the graph
typeMap map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if route does not use custom NavTypes.
enterTransition callback to define enter transitions for destination in this host
exitTransition callback to define exit transitions for destination in this host
popEnterTransition callback to define popEnter transitions for destination in this host
popExitTransition callback to define popExit transitions for destination in this host
sizeTransform callback to define the size transform for destinations in this host
builder the builder used to construct the graph

Common
@Composable
public fun NavHost(
    navController: NavHostController,
    startDestination: KClass<*>,
    modifier: Modifier = Modifier,
    contentAlignment: Alignment = Alignment.TopStart,
    route: KClass<*>? = null,
    typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
    enterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        DefaultNavTransitions.enterTransition,
    exitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        DefaultNavTransitions.exitTransition,
    popEnterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        enterTransition,
    popExitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        exitTransition,
    predictivePopEnterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> EnterTransition) =
        DefaultNavTransitions.predictivePopEnterTransition,
    predictivePopExitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> ExitTransition) =
        DefaultNavTransitions.predictivePopExitTransition,
    sizeTransform:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
        DefaultNavTransitions.sizeTransform,
    builder: NavGraphBuilder.() -> Unit,
)

Provides a place in the Compose hierarchy for self contained navigation to occur.

Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.

The builder passed into this method is remembered. This means that for this NavHost, the contents of the builder cannot be changed.

Parameters

navController the navController for this host
startDestination the route from a KClass for the start destination
modifier The modifier to be applied to the layout.
contentAlignment The Alignment of the AnimatedContent
route the route from a KClass for the graph
typeMap map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if route does not use custom NavTypes.
enterTransition callback to define enter transitions for destination in this host
exitTransition callback to define exit transitions for destination in this host
popEnterTransition callback to define popEnter transitions for destination in this host
popExitTransition callback to define popExit transitions for destination in this host
predictivePopEnterTransition callback to define predictivePopEnter transitions for destination in this host
predictivePopExitTransition callback to define predictivePopExit transitions for destination in this host
sizeTransform callback to define the size transform for destinations in this host
builder the builder used to construct the graph
Common
Deprecated Deprecated in favor of NavHost that supports predictivePopEnterTransition and predictivePopExitTransition

@Composable
public fun NavHost(
    navController: NavHostController,
    startDestination: Any,
    modifier: Modifier = Modifier,
    contentAlignment: Alignment = Alignment.TopStart,
    route: KClass<*>? = null,
    typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
    enterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        DefaultNavTransitions.enterTransition,
    exitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        DefaultNavTransitions.exitTransition,
    popEnterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        enterTransition,
    popExitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        exitTransition,
    sizeTransform:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
        DefaultNavTransitions.sizeTransform,
    builder: NavGraphBuilder.() -> Unit,
)

Provides in place in the Compose hierarchy for self contained navigation to occur.

Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.

The builder passed into this method is remembered. This means that for this NavHost, the contents of the builder cannot be changed.

Parameters

navController the navController for this host
startDestination the route from a an Object for the start destination
modifier The modifier to be applied to the layout.
contentAlignment The Alignment of the AnimatedContent
route the route from a KClass for the graph
typeMap map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if route does not use custom NavTypes.
enterTransition callback to define enter transitions for destination in this host
exitTransition callback to define exit transitions for destination in this host
popEnterTransition callback to define popEnter transitions for destination in this host
popExitTransition callback to define popExit transitions for destination in this host
sizeTransform callback to define the size transform for destinations in this host
builder the builder used to construct the graph

Common
@Composable
public fun NavHost(
    navController: NavHostController,
    startDestination: Any,
    modifier: Modifier = Modifier,
    contentAlignment: Alignment = Alignment.TopStart,
    route: KClass<*>? = null,
    typeMap: Map<KType, @JvmSuppressWildcards NavType<*>> = emptyMap(),
    enterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        DefaultNavTransitions.enterTransition,
    exitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        DefaultNavTransitions.exitTransition,
    popEnterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        enterTransition,
    popExitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        exitTransition,
    predictivePopEnterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> EnterTransition) =
        DefaultNavTransitions.predictivePopEnterTransition,
    predictivePopExitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> ExitTransition) =
        DefaultNavTransitions.predictivePopExitTransition,
    sizeTransform:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
        DefaultNavTransitions.sizeTransform,
    builder: NavGraphBuilder.() -> Unit,
)

Provides in place in the Compose hierarchy for self contained navigation to occur.

Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.

The builder passed into this method is remembered. This means that for this NavHost, the contents of the builder cannot be changed.

Parameters

navController the navController for this host
startDestination the route from a an Object for the start destination
modifier The modifier to be applied to the layout.
contentAlignment The Alignment of the AnimatedContent
route the route from a KClass for the graph
typeMap map of destination arguments' kotlin type KType to its respective custom NavType. May be empty if route does not use custom NavTypes.
enterTransition callback to define enter transitions for destination in this host
exitTransition callback to define exit transitions for destination in this host
popEnterTransition callback to define popEnter transitions for destination in this host
popExitTransition callback to define popExit transitions for destination in this host
predictivePopEnterTransition callback to define predictivePopEnter transitions for destination in this host
predictivePopExitTransition callback to define predictivePopExit transitions for destination in this host
sizeTransform callback to define the size transform for destinations in this host
builder the builder used to construct the graph
Common
Deprecated Deprecated in favor of NavHost that supports AnimatedContent

@Composable
public fun NavHost(
    navController: NavHostController,
    graph: NavGraph,
    modifier: Modifier = Modifier,
): Unit

Provides in place in the Compose hierarchy for self contained navigation to occur.

Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.

The graph passed into this method is remembered. This means that for this NavHost, the graph cannot be changed.

Parameters

navController the navController for this host
graph the graph for this host
modifier The modifier to be applied to the layout.
Common
Deprecated Deprecated in favor of NavHost that supports sizeTransform

@Composable
public fun NavHost(
    navController: NavHostController,
    graph: NavGraph,
    modifier: Modifier = Modifier,
    contentAlignment: Alignment = Alignment.TopStart,
    enterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        DefaultNavTransitions.enterTransition,
    exitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        DefaultNavTransitions.exitTransition,
    popEnterTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        enterTransition,
    popExitTransition: (AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        exitTransition,
)

Provides a place in the Compose hierarchy for self contained navigation to occur.

Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.

Parameters

navController the navController for this host
graph the graph for this host
modifier The modifier to be applied to the layout.
contentAlignment The Alignment of the AnimatedContent
enterTransition callback to define enter transitions for destination in this host
exitTransition callback to define exit transitions for destination in this host
popEnterTransition callback to define popEnter transitions for destination in this host
popExitTransition callback to define popExit transitions for destination in this host
Common
Deprecated Deprecated in favor of NavHost that supports predictivePopEnterTransition and predictivePopExitTransition

@Composable
public fun NavHost(
    navController: NavHostController,
    graph: NavGraph,
    modifier: Modifier = Modifier,
    contentAlignment: Alignment = Alignment.TopStart,
    enterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        DefaultNavTransitions.enterTransition,
    exitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        DefaultNavTransitions.exitTransition,
    popEnterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        enterTransition,
    popExitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        exitTransition,
    sizeTransform:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
        DefaultNavTransitions.sizeTransform,
)

Provides a place in the Compose hierarchy for self contained navigation to occur.

Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.

Parameters

navController the navController for this host
graph the graph for this host
modifier The modifier to be applied to the layout.
contentAlignment The Alignment of the AnimatedContent
enterTransition callback to define enter transitions for destination in this host
exitTransition callback to define exit transitions for destination in this host
popEnterTransition callback to define popEnter transitions for destination in this host
popExitTransition callback to define popExit transitions for destination in this host
sizeTransform callback to define the size transform for destinations in this host

Common
@Composable
public fun NavHost(
    navController: NavHostController,
    graph: NavGraph,
    modifier: Modifier = Modifier,
    contentAlignment: Alignment = Alignment.TopStart,
    enterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        DefaultNavTransitions.enterTransition,
    exitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        DefaultNavTransitions.exitTransition,
    popEnterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition) =
        enterTransition,
    popExitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition) =
        exitTransition,
    predictivePopEnterTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> EnterTransition) =
        DefaultNavTransitions.predictivePopEnterTransition,
    predictivePopExitTransition:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.(Int) -> ExitTransition) =
        DefaultNavTransitions.predictivePopExitTransition,
    sizeTransform:
        (@JvmSuppressWildcards
        AnimatedContentTransitionScope<NavBackStackEntry>.() -> SizeTransform?)? =
        DefaultNavTransitions.sizeTransform,
)

Provides a place in the Compose hierarchy for self contained navigation to occur.

Once this is called, any Composable within the given NavGraphBuilder can be navigated to from the provided navController.

Parameters

navController the navController for this host
graph the graph for this host
modifier The modifier to be applied to the layout.
contentAlignment The Alignment of the AnimatedContent
enterTransition callback to define enter transitions for destination in this host
exitTransition callback to define exit transitions for destination in this host
popEnterTransition callback to define popEnter transitions for destination in this host
popExitTransition callback to define popExit transitions for destination in this host
predictivePopEnterTransition callback to define predictivePopEnter transitions for destination in this host
predictivePopExitTransition callback to define predictivePopExit transitions for destination in this host
sizeTransform callback to define the size transform for destinations in this host