1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! [Inertia](https://inertiajs.com) lets you build a single-page app with React, Vue, or Svelte
//! while your Rust handlers keep the routing, controllers, and data.
//!
//! The [`Middleware`] trait shares props with every page and configures pages. Handlers call
//! [`render`], [`flash`], and [`location`], and build props with helpers such as [`lazy`] and
//! [`defer`]. [`on`] makes a prop live. To learn more, check out the
//! [Inertia guide](https://github.com/laravel/rust-framework/blob/0.x/docs/inertia.md).
//!
//! Add a `HandleInertiaRequests` middleware to the `web` group:
//!
//! ```
//! use laravel::http::{MiddlewareConfig, Request};
//! use laravel::inertia::{self, Props, props};
//!
//! pub struct HandleInertiaRequests;
//!
//! impl inertia::Middleware for HandleInertiaRequests {
//! async fn share(&self, _request: &Request) -> laravel::Result<Props> {
//! Ok(props! { name => laravel::config().app.name.clone() })
//! }
//! }
//!
//! fn configure(middleware: &mut MiddlewareConfig) {
//! middleware.web(|web| {
//! web.append(inertia::middleware(HandleInertiaRequests));
//! });
//! }
//! ```
//!
//! Handlers then render pages with [`render`]:
//!
//! ```no_run
//! use laravel::inertia::{self, Page, props};
//!
//! pub async fn show() -> Page {
//! inertia::render("Users/Show", props! { name => "Taylor" })
//! }
//! ```
//!
//! [`flash`] and [`location`] are also functions that handlers call directly. For anything else,
//! take the request's [`Inertia`] as a handler argument.
//!
//! By default, a first visit renders the [view](mod@crate::view) `app`, at
//! `resources/views/app.html`, as the root view. Assets come from Vite, and the asset version is
//! a hash of Vite's build manifest. Laravel renders pages on the server when
//! [`config::inertia::Inertia::ssr`](crate::config::inertia::Inertia::ssr) is on, such as with
//! `INERTIA_SSR=true`.
pub use ;