Skip to content

Commit e405e39

Browse files
update defining a root element page (#312)
* update setup page * Restructured * Update server-side-setup.jsx * Update client-side-setup.jsx --------- Co-authored-by: Pascal Baljet <[email protected]>
1 parent a870308 commit e405e39

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

resources/js/Pages/client-side-setup.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ export default function () {
211211
})
212212
`}
213213
/>
214+
<P>
215+
If you change the <Code>id</Code> of the root element, be sure to update it <A href="/server-side-setup#root-template">server-side</A> as well.
216+
</P>
214217
</>
215218
)
216219
}

resources/js/Pages/server-side-setup.jsx

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { A, Code, CodeBlock, H1, H2, P, TabbedCode } from '@/Components'
1+
import { A, Code, CodeBlock, H1, H2, Notice, P, TabbedCode } from '@/Components'
22
import dedent from 'dedent-js'
33

44
export const meta = {
@@ -48,9 +48,9 @@ export default function () {
4848
/>
4949
<H2>Root template</H2>
5050
<P>
51-
Next, setup the root template that will be loaded on the first page visit to your application. This will be used
52-
to load your site assets (CSS and JavaScript), and will also contain a root <Code>{'<div>'}</Code> in which to
53-
boot your JavaScript application.
51+
Next, setup the root template that will be loaded on the first page visit to your application. This template{' '}
52+
is responsible for loading your site assets (CSS and JavaScript). It should include your assets, as well{' '}
53+
as the <Code>@inertia</Code> and <Code>@inertiaHead</Code> directives.
5454
</P>
5555
<TabbedCode
5656
examples={[
@@ -74,9 +74,29 @@ export default function () {
7474
},
7575
]}
7676
/>
77+
<Notice>
78+
For React applications, it's recommended to include the <Code>@viteReactRefresh</Code> directive before the <Code>@vite</Code> directive to enable Fast Refresh in development.
79+
</Notice>
7780
<P>
78-
This template should include your assets, as well as the <Code>@inertia</Code> and <Code>@inertiaHead</Code>{' '}
79-
directives. For React applications, it's recommended to include the <Code>@viteReactRefresh</Code> directive before the <Code>@vite</Code> directive to enable Fast Refresh in development.
81+
The <Code>@inertia</Code> directive renders a <Code>{'<div>'}</Code> element with an <Code>id</Code> of <Code>app</Code>.{' '}
82+
This element serves as the mounting point for your JavaScript application. You may customize the <Code>id</Code> by passing a{' '}
83+
different value to the directive.
84+
</P>
85+
<CodeBlock
86+
language="markup"
87+
children={dedent`
88+
<!DOCTYPE html>
89+
<html>
90+
...
91+
<body>
92+
@inertia('custom-app-id')
93+
</body>
94+
</html>
95+
`
96+
}
97+
/>
98+
<P>
99+
If you change the <Code>id</Code> of the root element, be sure to update it <A href="/client-side-setup#defining-a-root-element">client-side</A> as well.
80100
</P>
81101
<P>
82102
By default, Inertia's Laravel adapter will assume your root template is named <Code>app.blade.php</Code>. If you

0 commit comments

Comments
 (0)