NavHost

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 fields

abstract @NonNull NavController

The navigation controller for this navigation host.

Extension functions

final default @NonNull NavGraph
NavHostKt.createGraph(
    @NonNull NavHost receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

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

final default @NonNull NavGraph
NavHostKt.createGraph(
    @NonNull NavHost receiver,
    @NonNull String startDestination,
    @Nullable String route,
    @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a new NavGraph

final default @NonNull NavGraph
NavHostKt.createGraph(
    @NonNull NavHost receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder
)

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

final default @NonNull NavGraph
NavHostKt.createGraph(
    @NonNull NavHost receiver,
    @NonNull String startDestination,
    @Nullable String route,
    @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder
)

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

Public fields

@NonNull
abstract @NonNull NavController navController

The navigation controller for this navigation host.

Extension functions

NavHostKt.createGraph

@NonNull
final default NavGraph NavHostKt.createGraph(
    @NonNull NavHost receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a new NavGraph

NavHostKt.createGraph

@NonNull
final default NavGraph NavHostKt.createGraph(
    @NonNull NavHost receiver,
    @NonNull String startDestination,
    @Nullable String route,
    @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a new NavGraph

NavHostKt.createGraph

@NonNull
final default NavGraph NavHostKt.createGraph(
    @NonNull NavHost receiver,
    @IdRes int id,
    @IdRes int startDestination,
    @NonNull Function1<@NonNull