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:
| File / Folder | Generated Route | Behavior |
|---|---|---|
brews.kt | Routes.Brews | Standard page |
brew/_id.kt | Routes.Brew.Id(id) | Dynamic path parameter (_id = path identity) |
files/__path.kt | Routes.Files.Path(path) | Catch-all wildcard segment |
_group_main/_layout.kt | Tab shell (@TabsLayout) | Independent back stack & scroll state per tab |
log_brew.kt | Routes.LogBrew(method, dose) | Optional function params become live query params |
_not_found.kt | Fallback route | Unmatched 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:
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):
@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?
Accessibility, Semantics & Focus
Zero-overhead TalkBack AccessibilityNodeProvider, reactive Modifier.semantics, keyboard navigation, and FocusRequester.
Server Data (crow-query)
Pure-JVM, typed server-state caching inspired by TanStack Query — built natively on Crow resources, held transitions, and optimistic actions.