Skip to content
Guest
Kotlin & Android · Course Syllabus Show lessons
Architecture · 8 min read · Intermediate

Screen Navigation with Navigation Compose

Wire multi-screen flows with type-safe routes, back-stack handling, and deep links.

What you'll learn

  • Define clear routes inside `NavHost`
  • Handle back-stack pops cleanly with `popUpTo` and `launchSingleTop`
  • Keep screen composables decoupled from `NavController`

Overview

Wire multi-screen flows with type-safe routes, back-stack handling, and deep links.

Code Example

NavHost(navController = navController, startDestination = "home") {
    composable("home") { HomeScreen(onOpen = { slug -> navController.navigate("course/$slug") }) }
    composable("course/{slug}") { backStack ->
        val slug = backStack.arguments?.getString("slug").orEmpty()
        CourseScreen(slug = slug)
    }
}

Key Takeaways

  • Define clear routes inside NavHost
  • Handle back-stack pops cleanly with popUpTo and launchSingleTop
  • Keep screen composables decoupled from NavController

Quick Check

Check Your Understanding

Score: 0 / 1

1. Why is passing navigation callback lambdas (`onBack: () -> Unit`) better than passing `NavController` into every screen?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind