Expand description
veer — Inertia.js v3 server-side protocol for Rust.
Build classic server-rendered apps that drive React, Vue, or Svelte frontends through the official Inertia.js client adapters — no separate JSON API needed.
See https://inertiajs.com/the-protocol for the protocol spec.
§Quick start (axum)
use veer::{Inertia, InertiaConfig, InertiaLayer, MinimalRootView};
use axum::{Router, routing::get};
let config = InertiaConfig::new()
.version(|| "1".into())
.root_view(MinimalRootView::new().title("Acme").vite_entry("/src/main.tsx"));
let app: Router = Router::new()
.route("/", get(|inertia: Inertia| async move {
inertia.render("Home", serde_json::json!({ "msg": "hello" }))
}))
.layer(InertiaLayer::new(config));§Feature flags
| Flag | Default | Purpose |
|---|---|---|
axum | on | Axum extractor + tower layer |
ssr | off | HTTP SSR client backed by reqwest |
cookie-session | off | Signed-cookie session store |
validator | off | IntoErrorBag impl for validator::ValidationErrors |
garde | off | IntoErrorBag impl for garde::Report |
§Architecture
- Protocol core: pure data + decision logic, no I/O. Lives in
protocol,page,props,request. - Pluggable traits:
RootView,SessionStore,SsrClient,SharedProps— implement your own or use the built-ins. - Adapters:
adapters::axumunder theaxumfeature.
§Caveats
Always<T>andMerge<T>wrappers are detected at any depth inside a typedSerializevalue, but only top-level matches affect the Inertia wire format (the protocol has no notion of “nested merge prop”).- When building props with the
serde_json::json!macro, wrappers are collapsed into raw values before they reachInertia::render— they only survive via typed#[derive(Serialize)]structs. UseInertiaResponse::mergeto mark top-level keys built viajson!.
Re-exports§
pub use config::InertiaConfig;pub use error::VeerError;pub use inertia::Inertia;pub use page::PageObject;pub use props::Always;pub use props::Merge;pub use request::RequestInfo;pub use response::InertiaResponse;pub use root_view::MinimalRootView;pub use root_view::RootView;pub use root_view::RootViewContext;pub use root_view::ViteManifest;pub use root_view::ViteRootView;pub use session::Flash;pub use session::SessionStore;pub use ssr::SsrClient;pub use ssr::SsrPayload;pub use adapters::axum::InertiaForm;pub use adapters::axum::InertiaFormRejection;pub use adapters::axum::InertiaLayer;pub use adapters::axum::Method;pub use adapters::axum::Router;
Modules§
- adapters
- Framework adapters.
- config
- Configuration assembled at app startup.
- error
- Crate error type.
- errors
- Bridges between Rust validation crates and Inertia’s flat
{field: message}error shape. - headers
- Inertia HTTP header names.
- inertia
- The per-request
Inertiafacade. - page
- The Inertia “page object” — the JSON payload that drives the client adapter.
- props
- Prop wrappers and resolution machinery.
- protocol
- Protocol state machine: decide the response shape for a given request + page.
- request
- Per-request data parsed from Inertia headers.
- response
- The response value handlers return.
- root_
view - Root HTML document rendering.
- session
- Session/flash store contract for cross-redirect prop data (errors, success messages).
- shared
- Shared props: per-config props merged into every response.
- ssr
- Server-side rendering integration.