pub struct InertiaConfig {
pub app_name: String,
pub vite_dev_server: String,
pub entry_point: String,
pub version: String,
pub development: bool,
pub html_template: Option<String>,
pub manifest_path: String,
pub title: Option<String>,
pub head_extras: Option<String>,
pub mount_id: String,
}Expand description
Configuration for Inertia.js responses.
§Example
use ferro_inertia::InertiaConfig;
// Development configuration (default)
let config = InertiaConfig::default();
// Production configuration
let config = InertiaConfig::new()
.version("1.0.0")
.production();
// Custom Vite dev server
let config = InertiaConfig::new()
.vite_dev_server("http://localhost:3000")
.entry_point("src/app.tsx");Fields§
§app_name: StringApplication name used in the HTML title tag
vite_dev_server: StringVite dev server URL (e.g., “http://localhost:5173”)
entry_point: StringEntry point for the frontend (e.g., “src/main.tsx”)
version: StringAsset version for cache busting
development: boolWhether we’re in development mode (use Vite dev server)
html_template: Option<String>Custom HTML template (if None, uses default)
manifest_path: StringPath to Vite’s manifest.json for resolving hashed asset filenames
title: Option<String>Optional page title. When Some, overrides app_name in <title>.
head_extras: Option<String>Raw HTML injected into <head> before </head> (meta, favicon, font tags).
SECURITY: developer-controlled config only — never populate from request data.
Ignored when html_template is set (the custom template owns <head>).
mount_id: Stringid attribute of the mount node. Defaults to "app".
Implementations§
Source§impl InertiaConfig
impl InertiaConfig
Sourcepub fn from_env() -> InertiaConfig
pub fn from_env() -> InertiaConfig
Build configuration from environment variables.
Reads APP_NAME, VITE_DEV_SERVER, VITE_ENTRY_POINT, INERTIA_VERSION,
and APP_ENV. Mirrors the framework from_env() convention.
Sourcepub fn new() -> InertiaConfig
pub fn new() -> InertiaConfig
Create a new configuration with default values.
Sourcepub fn vite_dev_server(self, url: impl Into<String>) -> InertiaConfig
pub fn vite_dev_server(self, url: impl Into<String>) -> InertiaConfig
Set the Vite dev server URL.
Sourcepub fn entry_point(self, entry: impl Into<String>) -> InertiaConfig
pub fn entry_point(self, entry: impl Into<String>) -> InertiaConfig
Set the frontend entry point.
Sourcepub fn version(self, version: impl Into<String>) -> InertiaConfig
pub fn version(self, version: impl Into<String>) -> InertiaConfig
Set the asset version for cache busting.
Sourcepub fn production(self) -> InertiaConfig
pub fn production(self) -> InertiaConfig
Enable production mode (disables Vite dev server integration).
Sourcepub fn development(self) -> InertiaConfig
pub fn development(self) -> InertiaConfig
Enable development mode (enables Vite dev server integration).
Sourcepub fn app_name(self, name: impl Into<String>) -> InertiaConfig
pub fn app_name(self, name: impl Into<String>) -> InertiaConfig
Set the application name used in the HTML title tag.
Sourcepub fn manifest_path(self, path: impl Into<String>) -> InertiaConfig
pub fn manifest_path(self, path: impl Into<String>) -> InertiaConfig
Set the path to Vite’s manifest.json.
Sourcepub fn html_template(self, template: impl Into<String>) -> InertiaConfig
pub fn html_template(self, template: impl Into<String>) -> InertiaConfig
Set a custom HTML template.
The template should contain the following placeholders:
{page}- The escaped JSON page data{csrf}- The CSRF token (optional)
§Example
use ferro_inertia::InertiaConfig;
let template = r#"
<!DOCTYPE html>
<html>
<head><title>My App</title></head>
<body>
<div id="app" data-page="{page}"></div>
<script src="/app.js"></script>
</body>
</html>
"#;
let config = InertiaConfig::new()
.html_template(template);Sourcepub fn title(self, t: impl Into<String>) -> InertiaConfig
pub fn title(self, t: impl Into<String>) -> InertiaConfig
Override the <title> tag. When None, falls back to app_name.
Sourcepub fn head_extras(self, h: impl Into<String>) -> InertiaConfig
pub fn head_extras(self, h: impl Into<String>) -> InertiaConfig
Raw HTML injected into <head> before </head>.
Ignored when html_template is set.
Sourcepub fn mount_id(self, id: impl Into<String>) -> InertiaConfig
pub fn mount_id(self, id: impl Into<String>) -> InertiaConfig
Set the mount node id (default "app").
Trait Implementations§
Source§impl Clone for InertiaConfig
impl Clone for InertiaConfig
Source§fn clone(&self) -> InertiaConfig
fn clone(&self) -> InertiaConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InertiaConfig
impl Debug for InertiaConfig
Source§impl Default for InertiaConfig
impl Default for InertiaConfig
Source§fn default() -> InertiaConfig
fn default() -> InertiaConfig
Auto Trait Implementations§
impl Freeze for InertiaConfig
impl RefUnwindSafe for InertiaConfig
impl Send for InertiaConfig
impl Sync for InertiaConfig
impl Unpin for InertiaConfig
impl UnsafeUnpin for InertiaConfig
impl UnwindSafe for InertiaConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more