Connect with us


Compose Navigation Reimagined – Type-safe navigation library for Jetpack Compose

A small and simple, yet fully fledged and customizable navigation library for Jetpack Compose:

  • Full type-safety
  • Built-in state restoration
  • Nested navigation with independent backstacks
  • Own Lifecycle, ViewModelStore and SavedStateRegistry for every backstack entry
  • Animated transitions
  • Dialog and bottom sheet navigation
  • Ability to define scopes for easy sharing of ViewModels
  • No builders, no obligatory superclasses for your composables

Quick start

Add a single dependency to your project:


Define a set of screens. It is convenient to use a sealed class for this:

sealed class Screen : Parcelable {

    object First : Screen()

    data class Second(val id: Int) : Screen()

    data class Third(val text: String) : Screen()


Create a composable with NavControllerNavBackHandler and NavHost:

fun NavHostScreen() {
    val navController = rememberNavController<Screen>(
        startDestination = Screen.First


    NavHost(navController) { screen ->
        when (screen) {
            is Screen.First -> Column {
                Text("First screen")
                Button(onClick = {
                    navController.navigate(Screen.Second(id = 42))
                }) {
                    Text("Open Second screen")

            is Screen.Second -> Column {
                Text("Second screen: ${}")
                Button(onClick = {
                    navController.navigate(Screen.Third(text = "Hello"))
                }) {
                    Text("Open Third screen")

            is Screen.Third -> {
                Text("Third screen: ${screen.text}")

As you can see, NavController is used for switching between screens, NavBackHandler handles back presses and NavHost provides a composable corresponding to the last destination in the backstack. As simple as that.


Full documentation is available here.

Additional dependencies

Library-specific hiltViewModel() implementation:


Support for bottom sheets navigation through BottomSheetNavHost:



Explore the sample. It demonstrates:

  • passing values and returning results
  • animated transitions
  • dialog and bottom sheet navigation
  • nested navigation
  • BottomNavigation integration
  • entry-scoped and shared ViewModels
  • hoisting of NavController to the ViewModel layer
  • deeplinks


I’ve been thinking about Android app architecture and navigation in particular for the longest time. After being introduced to Compose I could finally create the navigation structure that satisfies all my needs perfectly.

I hope it can help you as well.

Compose Navigation Reimagined on GitHub:
Platform: Android
⭐️: 261