Android 12 Developer Preview is here! Try it out, and give us your feedback!

androidx.navigation.compose

Classes

ComposeNavigator

Navigator that navigates through Composables.

NamedNavArgument

Construct a named NavArgument by using the navArgument method.

Top-level constants summary

const String

The route linked to the current destination.

Top-level functions summary

Unit
NavHost(navController: NavHostController, startDestination: String, route: String? = null, builder: NavGraphBuilder.() -> Unit)

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

Unit
NavHost(navController: NavHostController, graph: NavGraph)

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

NamedNavArgument
navArgument(name: String, builder: NavArgumentBuilder.() -> Unit)

Construct a new NavArgument

NavHostController

Creates a NavHostController that handles the adding of the ComposeNavigator.

Extension functions summary

For NavGraphBuilder
Unit
NavGraphBuilder.composable(route: String, arguments: List<NamedNavArgument> = emptyList(), deepLinks: List<NavDeepLink> = emptyList(), content: (NavBackStackEntry) -> Unit)

Add the Composable to the NavGraphBuilder

Unit
NavGraphBuilder.navigation(startDestination: String, route: String, builder: NavGraphBuilder.() -> Unit)

Construct a nested NavGraph

For NavController
NavGraph
NavController.createGraph(startDestination: String, route: String? = null, builder: NavGraphBuilder.() -> Unit)

Construct a new NavGraph

State<NavBackStackEntry?>

Gets the current navigation back stack entry as a MutableState.

NavBackStackEntry

Gets the topmost {@link NavBackStackEntry} for a route.

Unit
NavController.navigate(route: String, builder: NavOptionsBuilder.() -> Unit = {})

Navigate to a route in the current NavGraph.

For NavOptionsBuilder
Unit
NavOptionsBuilder.popUpTo(route: String, popUpToBuilder: PopUpToBuilder.() -> Unit)

Pop up to a given destination before navigating.

Top-level constants

KEY_ROUTE

const val KEY_ROUTE: String

The route linked to the current destination.

Value: "android-support-nav:controller:route"

Top-level functions

@Composable fun NavHost(
    navController: NavHostController,
    startDestination: