The Inertia protocol handles the first visit differently from subsequent navigations to avoid full page reloads:
- First Visit: The browser makes a standard GET request. The server responds with a full HTML document containing a root
<div> (mounting point) and a <script type="application/json"> element containing the initial Page Object. This boots the client-side framework. - Subsequent Visits: Inertia makes XHR requests with the
X-Inertia: true header. The server responds with a JSON payload (the Page Object) instead of HTML. Inertia then swaps the page component and updates the URL without reloading the page.
sequenceDiagram
participant Client
participant Server
Client->>Server: First Visit
Server-->>Client: Returns HTML Skeleton
Note over Client: Inertia.js is loaded
Client->>Server: Inertia Request (X-Inertia: true)
Server-->>Client: Returns JSON Payload (Component Name, Props, etc.)
Note over Client: Inertia.js swaps components