You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: v1/core-concepts/the-protocol.mdx
+230-1Lines changed: 230 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,4 +10,233 @@ This page contains a detailed specification of the Inertia protocol. Be sure to
10
10
11
11
The very first request to an Inertia app is just a regular, full-page browser request, with no special Inertia headers or data. For these requests, the server returns a full HTML document.
12
12
13
-
{/* This HTML response includes the site assets (CSS, JavaScript) as well as a root `<div>` in the page's body. The root `<div>` serves as a mounting point for the client-side app, and includes adata-page attribute with a JSON encoded <a href="#the-page-object">page object</a> for the initialpage. Inertia uses this information to boot your client-side framework and display the initial page component.<div classname="overflow-hidden rounded"><div classname="px-6 pt-6 font-mono text-sm text-white"><div classname="text-xs font-bold uppercase text-gray-600">Request</div><div classname="mt-1"><span classname="text-blue-400">GET:</span> http://example.com/events/80</div><div><span classname="text-blue-400">Accept:</span> text/html, application/xhtml+xml</div><div classname="mt-8 text-xs font-bold uppercase text-gray-600">Response</div><div classname="mt-1">HTTP/1.1 200 OK</div><div><span classname="text-blue-400">Content-Type:</span> text/html; charset=utf-8</div></div><p><codeblock>mT5keZcVVw</codeblock></p><p><codeblock>tGbPYOhrQq</codeblock></p><p><codeblock>73mMeawQzt</codeblock></p></div></div></div>` */}
13
+
This HTML response includes the site assets (CSS, JavaScript) as well as a root `<div>` in the
14
+
page's body. The root `<div>` serves as a mounting point for the client-side app, and includes a
15
+
`data-page` attribute with a JSON encoded <ahref="#the-page-object">page object</a> for the initial
16
+
page. Inertia uses this information to boot your client-side framework and display the initial page component.
<divid="app"data-page='{"component":"Event","props":{"event":{"id":80,"title":"Birthday party","start_date":"2019-06-02","description":"Come out and celebrate Jonathan's 36th birthday party!"}},"url":"/events/80","version":"c32b8e4965f418ad16eaebba1d4e960f"}'></div>
42
+
</body>
43
+
</html>
44
+
```
45
+
</div>
46
+
47
+
<Info>
48
+
While the initial response is HTML, Inertia does not server-side render the JavaScript page components.
49
+
</Info>
50
+
51
+
## Inertia responses
52
+
53
+
Once the Inertia app has been booted, all subsequent requests to the site are made via XHR with a
54
+
`X-Inertia` header set to `true`. This header indicates that the request is being made by
55
+
Inertia and isn't a standard full-page visit.
56
+
57
+
When the server detects the `X-Inertia` header, instead of responding with a full HTML document, it
58
+
returns a JSON response with an encoded <ahref="#the-page-object">page object</a>.
0 commit comments