Skip to main content

Crate veer

Crate veer 

Source
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

FlagDefaultPurpose
axumonAxum extractor + tower layer
ssroffHTTP SSR client backed by reqwest
cookie-sessionoffSigned-cookie session store
validatoroffIntoErrorBag impl for validator::ValidationErrors
gardeoffIntoErrorBag impl for garde::Report

§Architecture

§Caveats

  • Always<T> and Merge<T> wrappers are detected at any depth inside a typed Serialize value, 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 reach Inertia::render — they only survive via typed #[derive(Serialize)] structs. Use InertiaResponse::merge to mark top-level keys built via json!.

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 shared::SharedProps;
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 Inertia facade.
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.