How we built a file-based router that runs on five Rust UI frameworks

In Rust desktop and WASM applications, routing is often an afterthought: a global Route enum, a giant match block, and manual async fetching inside component mount hooks. When you switch UI toolkits, you throw the whole navigation layer away.
Navi brings TanStack Router semantics—file-based route trees, loaders, guards, and devtools—to Rust without coupling the router to a single UI crate.
The Goal
Section titled “The Goal”We wanted build-time route generation from src/routes, typed path and query parameters, before_load redirects, and scroll restoration, all running unmodified across GPUI, Dioxus, Leptos, Xilem, and Floem.
The Architecture
Section titled “The Architecture”navi-router-core contains zero UI dependencies and no hardcoded async runtime. It matches URLs against a ranked radix trie using interned Arc<str> segments and stack-collected parameter bindings, delegating reactive state and rendering to quoin.
Build-Time Route Tree
navi-codegen scans src/routes in build.rs and emits a validated route tree alongside typed use_params! and use_search! macros.
Loaders & Blockers
Routes support stale-while-revalidate data loaders (backed by rs-query), before_load guards, and async blockers for unsaved forms.
Allocation-Free Matching
Active link checks compare bytes directly, and per-frame hooks read cached navigation state without allocating on the heap.
Cross-Framework Devtools
Pressing Cmd+Shift+D opens an inspectable panel showing the route tree, cache entries, event timeline, and active blockers.
What it cost
Section titled “What it cost”Keeping the core framework-free meant enforcing strict workspace rules: #![forbid(unsafe_code)], pedantic Clippy lints with zero #[allow] suppressions, and maintaining five separate host demos (demo-gpui, demo-dioxus, demo-floem, demo-xilem, demo-leptos) over one shared demo-core crate.
Getting started
Section titled “Getting started”cargo run -p navi-demo-gpuiRead the getting started tutorial to configure navi.config.json and define your first route.
