Skip to content

Commit 28f1aa9

Browse files
committed
Update client side
1 parent 7a2937d commit 28f1aa9

File tree

6 files changed

+26
-2
lines changed

6 files changed

+26
-2
lines changed

docs/guide/client-side-setup.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,3 +295,23 @@ createInertiaApp({
295295

296296
> [!NOTE]
297297
> Make sure the [`root_dom_id`](/guide/configuration#root_dom_id) configuration option matches the `id` property in your client-side setup.
298+
299+
## Script Element for Page Data
300+
301+
By default, Inertia stores the initial page data in a `data-page` attribute on the root element. You may configure Inertia to use a `<script type="application/json">` element instead, which is slightly faster and easier to inspect in your browser's dev tools.
302+
303+
```js
304+
createInertiaApp({
305+
// ...
306+
defaults: {
307+
future: {
308+
useScriptElementForInitialPage: true,
309+
},
310+
},
311+
})
312+
```
313+
314+
You should also set the [`use_script_element_for_initial_page`](/guide/configuration#use_script_element_for_initial_page) config option to `true`.
315+
316+
> [!NOTE]
317+
> Be sure to also update your [SSR entry point](/guide/server-side-rendering#add-server-entry-point) if you're using server-side rendering.

docs/guide/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ end
175175
**Default**: `false`
176176
**ENV**: `INERTIA_USE_SCRIPT_ELEMENT_FOR_INITIAL_PAGE`
177177

178-
@available_since rails=master core=master
178+
@available_since rails=master core=2.2.20
179179

180180
When enabled the initial page data is rendered in a `<script type="application/json">` element instead of the `data-page` attribute on the root `<div>`.
181181
This provides two main benefits:
@@ -206,4 +206,4 @@ When enabled, the HTML output looks like:
206206

207207
> [!NOTE]
208208
> When using this option make sure your client-side Inertia setup is configured to read the page data from the `<script>` element.
209-
> See the [protocol documentation](/guide/the-protocol#html-responses) for more details.
209+
> See the [client side setup](/guide/client-side-setup#script-element-for-page-data) for more details.

lib/generators/inertia/install/templates/react/inertia.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ createInertiaApp({
4444
forceIndicesArrayFormatInFormData: false,
4545
},
4646
future: {
47+
useScriptElementForInitialPage: true,
4748
useDataInertiaHeadAttribute: true,
4849
useDialogForErrorModal: true,
4950
preserveEqualProps: true,

lib/generators/inertia/install/templates/react/inertia.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ void createInertiaApp({
4444
forceIndicesArrayFormatInFormData: false,
4545
},
4646
future: {
47+
useScriptElementForInitialPage: true,
4748
useDataInertiaHeadAttribute: true,
4849
useDialogForErrorModal: true,
4950
preserveEqualProps: true,

lib/generators/inertia/install/templates/svelte/inertia.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ createInertiaApp({
4242
forceIndicesArrayFormatInFormData: false,
4343
},
4444
future: {
45+
useScriptElementForInitialPage: true,
4546
useDataInertiaHeadAttribute: true,
4647
useDialogForErrorModal: true,
4748
preserveEqualProps: true,

lib/generators/inertia/install/templates/vue/inertia.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ createInertiaApp({
4141
forceIndicesArrayFormatInFormData: false,
4242
},
4343
future: {
44+
useScriptElementForInitialPage: true,
4445
useDataInertiaHeadAttribute: true,
4546
useDialogForErrorModal: true,
4647
preserveEqualProps: true,

0 commit comments

Comments
 (0)