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/docs/v3/core-concepts/the-protocol for the protocol spec.

§Quick start (axum)

use veer::{Inertia, InertiaConfig, InertiaLayer, MinimalRootView};
use axum::{Router, routing::get};

let config = InertiaConfig::new()
    .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
multipartoffFile upload support (UploadedFile, MultipartStream)
cookie-sessionoffSigned-cookie session store
tower-sessionsoffFlash store backed by tower-sessions
validatoroffIntoErrorBag impl for validator::ValidationErrors
gardeoffIntoErrorBag impl for garde::Report
csrfoffInertia/axios-compatible CSRF layer (CsrfLayer)
embedoffEmbedded-asset serving service (EmbeddedAssets)
devtoolsoffRecorder + read API for the Inertia DevTools browser extension
tsoffTypeScript bindings codegen (ts-rs + inventory)
testingoffHelpers for tests of your handlers (testing)

§Architecture

§Caveats

  • Always<T> and Merge<T> wrappers are detected at any depth and through any serialization path (typed structs, serde_json::json!, hand-built Values). A nested wrapper acts at its dot path (posts.data).

Re-exports§

pub use config::InertiaConfig;
pub use csrf::CsrfTokens;csrf
pub use devtools::DevTools;devtools
pub use error::VeerError;
pub use head::Head;
pub use inertia::Inertia;
pub use page::PageObject;
pub use props::Always;
pub use props::Merge;
pub use props::Prop;
pub use props::ScrollMetadata;
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::ViteManifestError;
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;axum
pub use adapters::axum::InertiaFormRejection;axum
pub use adapters::axum::InertiaLayer;axum
pub use adapters::axum::Method;axum
pub use adapters::axum::MissingInertiaLayer;axum
pub use adapters::axum::Precognition;axum
pub use adapters::axum::Router;axum
pub use adapters::axum::GardeValidated;axum and garde
pub use adapters::axum::Validated;axum and validator
pub use adapters::axum::CsrfLayer;csrf
pub use adapters::axum::EmbeddedAssets;embed
pub use multipart::UploadedFile;multipart
pub use adapters::axum::MultipartStream;axum and multipart

Modules§

adaptersaxum
Framework adapters.
bigint
Big-integer transport: integers outside the JavaScript safe range travel as {"$bigint": "<digits>"} markers, which the client revives as BigInt.
bindingsts
End-to-end TypeScript bindings: generate a single .ts bundle from Rust prop structs and registered routes.
config
Configuration assembled at app startup.
csrfcsrf
Stateless, signed double-submit CSRF tokens (framework-agnostic).
devtoolsdevtools
Inertia DevTools protocol: records one entry per request for the Inertia DevTools browser extension.
error
Crate error type.
errors
Bridges between Rust validation crates and Inertia’s flat {field: message} error shape.
head
Server-provided <head> elements for the client’s serverHead option.
headers
Inertia HTTP header names.
inertia
The per-request Inertia facade.
multipartmultipart
File upload support for multipart/form-data bodies.
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.
testingtesting
Helpers for tests of your handlers (testing feature).

Macros§

register_pagets
Register a Rust prop struct as an Inertia page component for TS bindings.