public interface NavHost
Known direct subclasses
NavHostFragment

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

Known indirect subclasses

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:

  • Handle saving and restoring their controller's state

  • Call Navigation.setViewNavController on their root view

  • Route system Back button events to the NavController either by manually calling NavController.popBackStack or by calling NavHostController.setOnBackPressedDispatcher when constructing the NavController.

Optionally, a navigation host should consider calling:

Summary

Extension functions

default final @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

default final @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

default final @NonNull NavGraph

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

Construct a new NavGraph

default final @NonNull NavGraph

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

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

default final @NonNull NavGraph

NavHostKt.createGraph(
    @NonNull NavHost receiver,
    @NonNull Object startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a new NavGraph

default final @NonNull NavGraph

NavHostKt.createGraph(
    @NonNull NavHost receiver,
    @NonNull Object startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder
)

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

default final @NonNull NavGraph

NavHostKt.createGraph(
    @NonNull NavHost receiver,
    @NonNull KClass<@NonNull ?> startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @NonNull Function1<@NonNull NavGraphBuilderUnit> builder
)

Construct a new NavGraph

default final @NonNull NavGraph

NavHostKt.createGraph(
    @NonNull NavHost receiver,
    @NonNull KClass<@NonNull ?> startDestination,
    KClass<@NonNull ?> route,
    @NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap,
    @NonNull Function1<@NonNull DynamicNavGraphBuilderUnit> builder
)

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

Public methods

Extension functions

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025-06-24 UTC.