You define the entire URL structure of your app through file and folder names inside your configured routes directory (default src/routes). The navi-codegen scanner turns those names into route patterns at build time.
Naming conventions
Section titled “Naming conventions”| File or folder | Pattern produced | Role |
|---|---|---|
index.rs |
/ (or the parent path) |
Index route for its directory |
$id.rs |
/$id |
Dynamic segment — one URL parameter |
$.rs |
splat / not-found | Catch-all; marks the route as not-found |
__root.rs |
/ |
Root layout wrapping every route |
_auth.rs or _auth/ |
— | Pathless layout — renders children without adding a URL segment |
(marketing)/ |
— | Group folder — organizes files without affecting the URL |
-draft.rs |
— | Ignored — files with the ignore prefix are skipped |
users.rs next to users/ |
/users |
Layout for the users/ directory |
All conventions come from the scanner, so they respond to the route_token, index_token, and route_file_ignore_prefix keys in navi.config.json (see the config reference).
Worked example
Section titled “Worked example”This tree is the layout of the repository’s own example-app:
Directorysrc/routes/
- __root.rs
- index.rs
- $.rs
- login.rs
- about.rs
Directory_auth/
- profile.rs
Directory(marketing)/
- about.rs
Directoryusers/
- index.rs
- $id.rs
- $.rs
Directorydashboard/
- index.rs
- settings.rs
- analytics.rs
Directoryadmin/
- dashboard.rs
Directorydocs/
- $.rs
From this tree the scanner produces, among others:
/— the root layout plus index page./users— the users index./users/$id— a dynamic user page./dashboard/settings— a nested page under the dashboard directory.- The
$.rsfiles mark not-found catch-alls at their level, and_auth/profile.rsrenders under a pathless layout: the URL is/profile, butprofilerenders inside the_authlayout.
Renaming the conventions
Section titled “Renaming the conventions”You are not locked into $ and index. The tokens are configuration:
{ "route_token": "route", "index_token": "index", "route_file_ignore_prefix": "-"}If you change route_token, dynamic segments and splats use your token instead of $ in file names.
Next steps
Section titled “Next steps”define_route! referenceAll accepted arguments, including is_layout and is_index.
navi.config.json referenceEvery code generation key with types and defaults.
