interface NavHost

Known direct subclasses
NavHostFragment

NavHostFragment provides an area within your layout for self-contained navigation to occur.

Known indirect subclasses
DynamicNavHostFragment

The NavHostFragment for dynamic features.


A host is a single context or container for navigation via a NavController.

It is strongly recommended to construct the nav controller by instantiating a NavHostController, which offers additional APIs specifically for a NavHost. The NavHostController should still only be externally accessible as a NavController, rather than directly exposing it as a NavHostController.

Navigation hosts must:

Optionally, a navigation host should consider calling:

Summary

Public properties

NavController

The navigation controller for this navigation host.

Extension functions

inline NavGraph
NavHost.createGraph(
    id: @IdRes Int,
    startDestination: @IdRes Int,
    builder: NavGraphBuilder.() -> Unit
)

This function is deprecated. Use routes to create your NavGraph instead

inline NavGraph
NavHost.createGraph(
    id: @IdRes Int,
    startDestination: @IdRes Int,
    builder: DynamicNavGraphBuilder.() -> Unit
)

This function is deprecated. Use routes to create your dynamic NavGraph instead

inline NavGraph
NavHost.createGraph(
    startDestination: String,
    route: String?,
    builder: NavGraphBuilder.() -> Unit
)

Construct a new NavGraph

inline NavGraph
NavHost.createGraph(
    startDestination: String,
    route: String?,
    builder: DynamicNavGraphBuilder.() -> Unit
)

Construct a new androidx.navigation.NavGraph that supports dynamic navigation destinations

Public properties

Added in 1.0.0
val navControllerNavController

The navigation controller for this navigation host.

Extension functions

inline fun NavHost.createGraph(
    id: @IdRes Int = 0,
    startDestination: @IdRes Int,
    builder: NavGraphBuilder.() -> Unit
): NavGraph

Construct a new NavGraph

inline fun NavHost.createGraph(
    id: @IdRes Int = 0,
    startDestination: @IdRes Int,
    builder: DynamicNavGraphBuilder.() -> Unit
): NavGraph

Construct a new androidx.navigation.NavGraph that supports dynamic navigation destinations

inline fun NavHost.createGraph(
    startDestination: String,
    route: String? = null,
    builder: NavGraphBuilder.() -> Unit
): NavGraph

Construct a new NavGraph

inline fun NavHost.createGraph(
    startDestination: String,
    route: String? = null,
    builder: DynamicNavGraphBuilder.() -> Unit
): NavGraph

Construct a new androidx.navigation.NavGraph that supports dynamic navigation destinations