Crate ferro_inertia

Crate ferro_inertia 

Source
Expand description

§Ferro Inertia

Server-side Inertia.js adapter for Rust web frameworks.

This crate provides the core functionality for building Inertia.js responses in Rust. It is framework-agnostic and can be integrated with any Rust web framework (Axum, Actix-web, Rocket, etc.).

§Features

  • Framework-agnostic design via traits
  • Async-safe (no thread-local storage)
  • Partial reload support
  • Shared props for auth, flash messages, CSRF tokens
  • Version conflict detection (409 responses)
  • Development mode with Vite HMR support

§Quick Start

use ferro_inertia::{Inertia, InertiaConfig, InertiaRequest};

// Implement InertiaRequest for your framework's request type
impl InertiaRequest for MyRequest {
    fn inertia_header(&self, name: &str) -> Option<&str> {
        self.headers().get(name).and_then(|v| v.to_str().ok())
    }
    fn path(&self) -> &str {
        self.uri().path()
    }
}

// In your handler
async fn index(req: MyRequest) -> MyResponse {
    let response = Inertia::render(&req, "Home", serde_json::json!({
        "title": "Welcome"
    }));

    // Convert InertiaHttpResponse to your framework's response type
    response.into()
}

§Framework Integrations

See the examples directory for integrations with popular frameworks:

  • Axum
  • Actix-web
  • Hyper

Re-exports§

pub use serde_json;

Structs§

Inertia
Main Inertia integration struct.
InertiaConfig
Configuration for Inertia.js responses.
InertiaHttpResponse
Framework-agnostic HTTP response.
InertiaResponse
Internal response builder.
InertiaShared
Shared props that are merged into every Inertia response.

Traits§

InertiaRequest
Trait for extracting Inertia-specific data from HTTP requests.