Skip to Content
CrowCrow

File-Based & Typed Routing

Type-safe file-based routing via crow.routes, independent tab histories, modal sheets, guards, and BackStack/NavHost.

crow-router (paired with the crow.routes Gradle plugin) turns your routes/ folder into a compile-time, type-safe navigation graph — inspired by Expo Router and Next.js App Router, built natively for Kotlin and Android.

Folder Conventions

Every Kotlin file under your routes/ directory becomes a strongly typed route on the generated Routes object:

_layout.kt
_not_found.kt
log_brew.kt
_layout.kt
brews.kt
beans.kt
studio.kt
_id.kt
File / FolderGenerated RouteBehavior
brews.ktRoutes.BrewsStandard page
brew/_id.ktRoutes.Brew.Id(id)Dynamic path parameter (_id = path identity)
files/__path.ktRoutes.Files.Path(path)Catch-all wildcard segment
_group_main/_layout.ktTab shell (@TabsLayout)Independent back stack & scroll state per tab
log_brew.ktRoutes.LogBrew(method, dose)Optional function params become live query params
_not_found.ktFallback routeUnmatched deep links

Declaring Pages & Sheets

A page's parameters are simply its @Page @Ui function parameters. Path parameters define entry identity; query parameters arrive as live props updated in place without remounting the screen:

routes/log_brew.kt
val logBrewConfig = routeConfig<Routes.LogBrew> {
    presentation = Presentation.Sheet
}

@Page
@Ui
fun LogBrewScreen(
    method: BrewMethod = BrewMethod.PourOver,
    dose: Int = 15,
    water: Int = 240,
) {
    val router = router()
    // ...
    Button(onClick = { router.dismiss() }) { Text("Done") }
}

Navigate from anywhere with full compile-time type safety:

val router = router()
router.navigate(Routes.Brew.Id(id = brew.id))
router.navigate(Routes.LogBrew(method = BrewMethod.Espresso, dose = 18))

Tab Shells with Independent Histories

Annotate a group layout with @TabsLayout and render SelectedTab(tabs):

routes/_group_main/_layout.kt
@TabsLayout("brews", "beans", "studio")
@Ui
fun MainTabs(@Once tabs: TabsScope) {
    Box(Modifier.fillMaxSize()) {
        SelectedTab(tabs)
        TabBar(
            items = tabItems,
            selected = tabs.selected,
            onSelect = tabs::select,
        )
    }
}

Switching tabs keeps covered tabs dormant (no layout, draw, or effects) while preserving their scroll position and sub-stack.

Low-Level BackStack & NavHost

If you prefer programmatic routing without file generation, crow-runtime provides BackStack<Route> and NavHost(stack) directly — complete with keepAlive dormant screens, ModalRoute, typed pushForResult, held data transitions (up to 150 ms so destination screens never flash empty), route transitions, shared elements, and 1:1 predictive back.

How is this guide?

On this page