Skip to content

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.

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).

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 $.rs files mark not-found catch-alls at their level, and _auth/profile.rs renders under a pathless layout: the URL is /profile, but profile renders inside the _auth layout.

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.