Skip to content
Back to skills

Android Navigation 3

ASecurity

Navigation 3 uses typed Kotlin values as routes instead of string patterns. A route with no arguments can be a `data object`; a route with arguments should be a `data class` whose properties hold those arguments. ```kotlin data object RouteHome data class RouteDetail(val id: String) data object RouteSettings ``` The argument is now a normal Kotlin property, so there is no `"detail/{id}"` placeholder, string interpolation, or `NavBackStackEntry` argument lookup. A route is created with the val...

  • 584 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 5, 2026
developmentkotlin

Security analysis

A100/100

Pro scans all 13 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill android-navigation-3 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Android Navigation 3?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Android Navigation 3
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-android-navigation-3-agent-skills-standard/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-android-navigation-3-agent-skills-standard)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Defining routes in Navigation 3

Navigation 3 uses typed Kotlin values as routes instead of string patterns. A route with no arguments can be a `data object`; a route with arguments should be a `data class` whose properties hold those arguments.

```kotlin
data object RouteHome
data class RouteDetail(val id: String)
data object RouteSettings
```

The argument is now a normal Kotlin property, so there is no `"detail/{id}"` placeholder, string interpolation, or `NavBackStackEntry` argument lookup. A route is created with the value it needs:

```kotlin
val detail = RouteDetail(id = "42")
```

The application owns a stateful list of route values and renders it with `NavDisplay`:

```kotlin
@Composable
fun AppNavigation() {
    val backStack = remember {
        mutableStateListOf<Any>(RouteHome)
    }

    NavDisplay(
        backStack = backStack,
        onBack = { backStack.removeLastOrNull() },
        entryProvider = { key ->
            when (key) {
                is RouteHome -> NavEntry(key) {
                    HomeScreen(
                        onOpenDetail = { id ->
                            backStack.add(RouteDetail(id = id))
                        },
                        onOpenSettings = {
                            backStack.add(RouteSettings)
                        }
                    )
                }

                is RouteDetail -> NavEntry(key) {
                    DetailScreen(id = key.id)
                }

                is RouteSettings -> NavEntry(key) {
                    SettingsScreen()
                }

                else -> error("Unknown route: $key")
            }
        }
    )
}
```

For example, `backStack.add(RouteDetail("42"))` is the Navigation 3 equivalent of `navController.navigate("detail/42")`, and `backStack.removeLastOrNull()` is the equivalent of popping. To return to a single root route, clear and repopulate the list:

```kotlin
backStack.clear()
backStack.add(RouteHome)
```

The important rules are:

- Use `data object` or `data class` route values rather than string route names.
- Put navigation arguments directly on the route data class.
- Keep the back stack as `mutableStateListOf<Any>` (usually inside `remember`).
- Handle every route in `NavDisplay`'s `entryProvider`; fail explicitly for an unknown route.
- If routes must be restored after process death, make them persistable as required by the chosen state-saving approach, such as `Parcelable` or `@Serializable` routes.

Files in this skill

  • eval-1.baseline.md2.4 KB
  • eval-1.with-skill.md2.4 KB
  • eval-2.baseline.md2.9 KB
  • eval-2.with-skill.md2.9 KB
  • eval-3.baseline.md4.7 KB
  • eval-3.with-skill.md3.4 KB
  • trigger-1.md147 B
  • trigger-2.md141 B
  • trigger-3.md121 B
  • trigger-4.md121 B
  • trigger-5.md107 B
  • trigger-6.md115 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.