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
| Flag | Default | Purpose |
|---|---|---|
axum | on | Axum extractor + tower layer |
ssr | off | HTTP SSR client backed by reqwest |
multipart | off | File upload support (UploadedFile, MultipartStream) |
cookie-session | off | Signed-cookie session store |
tower-sessions | off | Flash store backed by tower-sessions |
validator | off | IntoErrorBag impl for validator::ValidationErrors |
garde | off | IntoErrorBag impl for garde::Report |
csrf | off | Inertia/axios-compatible CSRF layer (CsrfLayer) |
embed | off | Embedded-asset serving service (EmbeddedAssets) |
devtools | off | Recorder + read API for the Inertia DevTools browser extension |
ts | off | TypeScript bindings codegen (ts-rs + inventory) |
testing | off | Helpers for tests of your handlers (testing) |
§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 and through any serialization path (typed structs,serde_json::json!, hand-builtValues). A nested wrapper acts at its dot path (posts.data).
Re-exports§
pub use config::InertiaConfig;pub use csrf::CsrfTokens;csrfpub use devtools::DevTools;devtoolspub 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 ssr::SsrClient;pub use ssr::SsrPayload;pub use adapters::axum::InertiaForm;axumpub use adapters::axum::InertiaFormRejection;axumpub use adapters::axum::InertiaLayer;axumpub use adapters::axum::Method;axumpub use adapters::axum::MissingInertiaLayer;axumpub use adapters::axum::Precognition;axumpub use adapters::axum::Router;axumpub use adapters::axum::GardeValidated;axumandgardepub use adapters::axum::Validated;axumandvalidatorpub use adapters::axum::CsrfLayer;csrfpub use adapters::axum::EmbeddedAssets;embedpub use multipart::UploadedFile;multipartpub use adapters::axum::MultipartStream;axumandmultipart
Modules§
- adapters
axum - Framework adapters.
- bigint
- Big-integer transport: integers outside the JavaScript safe range travel as
{"$bigint": "<digits>"}markers, which the client revives asBigInt. - bindings
ts - End-to-end TypeScript bindings: generate a single
.tsbundle from Rust prop structs and registered routes. - config
- Configuration assembled at app startup.
- csrf
csrf - Stateless, signed double-submit CSRF tokens (framework-agnostic).
- devtools
devtools - 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’sserverHeadoption. - headers
- Inertia HTTP header names.
- inertia
- The per-request
Inertiafacade. - multipart
multipart - File upload support for
multipart/form-databodies. - 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.
- testing
testing - Helpers for tests of your handlers (
testingfeature).
Macros§
- register_
page ts - Register a Rust prop struct as an Inertia page component for TS bindings.