Skip to content

You declare a search type on a route to work with query strings through typed structs instead of raw strings.

Give the route a search type and read it back with use_search!:

src/lib.rs
use navi_macros::{define_route, use_search};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct UserSearch {
pub sort: Option<String>,
pub page: Option<u32>,
}
UsersRoute,
path: "/users",
search: UserSearch,
node: users_node,
);

Inside the route’s UI, use_search!(UsersRoute) returns the parsed search struct for the current navigation.

Link accepts a search value, plus hash and state, so navigation carries query data without hand-building URLs:

use navi_router::components::Link;
Link::new("/users")
.search(serde_json::json!({ "sort": "desc", "page": 2 }))
.child("Users, descending")
.build()

Navi exposes a ValidateSearch trait with ValidationResult / ValidationError. With the validation integrations you connect this to validator, garde, validify, or valico.

Enable the nested-search feature for typed, bracket-nested query strings of the form filter[status]=open&tags[0]=rust, parsed via serde_qs. The feature re-exports two helpers from navi_router:

Helper Purpose
parse_query_nested Parse a bracket-nested query string into a nested value.
query_to_string Serialize a nested value back to a query string.