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
<Warning>This is documentation for Inertia.js v1, which is no longer actively maintained. Please refer to the [v2 docs](/v2) for the latest information.</Warning>
11
13
@@ -154,14 +156,14 @@ Next, we need to update our Vite configuration to build our new `ssr.js` file. W
@@ -171,7 +173,7 @@ Next, let's update the `build` script in our `package.json` file to also build o
171
173
172
174
```diff
173
175
"scripts": {
174
-
"dev": "vite",
176
+
"dev": "vite",
175
177
- "build": "vite build"
176
178
+ "build": "vite build && vite build --ssr"
177
179
},
@@ -195,13 +197,17 @@ With the server running, you should be able to access your app within the browse
195
197
196
198
## Client Side Hydration
197
199
200
+
<ClientSpecific>
198
201
Since your website is now being server-side rendered, you can instruct <VueSpecific>Vue</VueSpecific><ReactSpecific>React</ReactSpecific><SvelteSpecific>Svelte</SvelteSpecific> to "hydrate" the static markup and make it interactive instead of re-rendering all the HTML that we just generated.
202
+
</ClientSpecific>
199
203
200
-
{/* <vue2>Inertia automatically enables client-side hydration in Vue 2 apps, so no changes are required.*/}
204
+
<Vue2Specific>Inertia automatically enables client-side hydration in Vue 2 apps, so no changes are required.</Vue2Specific>
201
205
202
-
{/* </vue2><vue3>To enable client-side hydration in a Vue 3 app, update your `app.js` file to use `createSSRApp` instead of `createApp`:*/}
206
+
<Vue3Specific>To enable client-side hydration in a Vue 3 app, update your `app.js` file to use `createSSRApp` instead of `createApp`:</Vue3Specific>
203
207
204
-
{/* </vue3><ReactSpecific>To enable client-side hydration in a React app, update your `app.js` file to use `hydrateRoot` instead of `createRoot`:</ReactSpecific><SvelteSpecific>To enable client-side hydration in a Svelte app, set the `hydratable` compiler option to `true` in your `vite.config.js` file:</SvelteSpecific> */}
208
+
<ReactSpecific>To enable client-side hydration in a React app, update your `app.js` file to use `hydrateRoot` instead of `createRoot`:</ReactSpecific>
209
+
210
+
<SvelteSpecific>To enable client-side hydration in a Svelte app, set the `hydratable` compiler option to `true` in your `vite.config.js` file:</SvelteSpecific>
205
211
206
212
<CodeGroup>
207
213
@@ -269,7 +275,9 @@ Since your website is now being server-side rendered, you can instruct <VueSpeci
269
275
270
276
</CodeGroup>
271
277
272
-
{/* <SvelteSpecific>You'll also need to enable hydration in your `app.js` file: */}
278
+
<SvelteSpecific>
279
+
280
+
You'll also need to enable hydration in your `app.js` file:
273
281
274
282
```diff
275
283
import { createInertiaApp } from '@inertiajs/svelte'
@@ -286,9 +294,13 @@ Since your website is now being server-side rendered, you can instruct <VueSpeci
286
294
+ new App({ target: el, hydrate: true })
287
295
+ },
288
296
})
289
-
```</SvelteSpecific>## Deployment
297
+
```
298
+
299
+
</SvelteSpecific>
300
+
301
+
## Deployment
290
302
291
-
When deploying your SSR enabled app to production, you'll need to build both the client-side (`app.js`) and server-side bundles (`ssr.js`), and then run the SSR server as a background process, typically using a process monitoring tool such as Supervisor.
303
+
When deploying your SSR enabled app to production, you'll need to build both the client-side (`app.js`) and server-side bundles (`ssr.js`), and then run the SSR server as a background process, typically using a process monitoring tool such as Supervisor.
Copy file name to clipboardExpand all lines: v1/getting-started/upgrade-guide.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ For a complete list of all the changes, see the [release notes](https://github.c
16
16
17
17
## New Dependencies
18
18
19
-
To use previous Inertia releases, you had to install a number of libraries, including the core library (`@inertiajs/inertia`), the adapter of your choice (`@inertiajs/inertia-vue|vue3|react|svelte`), the progress library (`@inertiajs/progress`), and if you were using server-side rendering, the server library (`@inertiajs/server`).
19
+
To use previous Inertia releases, you had to install a number of libraries, including the core library (`@inertiajs/inertia`), the adapter of your choice (`@inertiajs/inertia-vue|vue3|react|svelte`), the progress library (`@inertiajs/progress`), and if you were using server-side rendering, the server library (`@inertiajs/server`).
20
20
21
21
**Moving forward you are now only required to install a single library** — the adapter of your choice (Vue, React, or Svelte), and all other core libraries are automatically installed for you.
Copy file name to clipboardExpand all lines: v1/the-basics/pages.mdx
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,7 +113,7 @@ class UserController extends Controller
113
113
114
114
## Creating Layouts
115
115
116
-
{/*While not required, for most projects it makes sense to create a site layout that all of your pages can extend. You may have noticed in our page example above that we're wrapping the page content within a `{`<layout>`}</layout>` component. Here's an example of such a component:*/}
116
+
While not required, for most projects it makes sense to create a site layout that all of your pages can extend. You may have noticed in our page example above that we're wrapping the page content within a `<Layout>` component. Here's an example of such a component:
117
117
118
118
<CodeGroup>
119
119
@@ -388,14 +388,18 @@ export default Home
388
388
389
389
</CodeGroup>
390
390
391
-
{/* <VueSpecific>If you're using Vue 2.7 or Vue 3, you can alternatively use the [defineOptions plugin](https://vue-macros.sxzz.moe/macros/define-options.html) to define a layout within `<script setup>`: */}
391
+
<VueSpecific>
392
+
If you're using Vue 2.7 or Vue 3, you can alternatively use the [defineOptions plugin](https://vue-macros.sxzz.moe/macros/define-options.html) to define a layout within `<script setup>`:
392
393
393
-
{/*```html
394
+
```html
394
395
<scriptsetup>
395
396
importLayoutfrom'./Layout'
396
397
defineOptions({ layout: Layout })
397
398
</script>
398
-
```</VueSpecific>## Default layouts */}
399
+
```
400
+
</VueSpecific>
401
+
402
+
## Default layouts
399
403
400
404
If you're using persistent layouts, you may find it convenient to define the default page layout in the `resolve()` callback of your application's main JavaScript file.
Copy file name to clipboardExpand all lines: v1/the-basics/responses.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ title: Responses
8
8
9
9
Creating an Inertia response is simple. To get started, invoke the `Inertia::render()` method within your controller or route, providing both the name of the [JavaScript page component](/v1/the-basics/pages) that you wish to render, as well as any props (data) for the page.
10
10
11
-
In the example below, we will pass a single prop (`event`) which contains four attributes (`id`, `title`, `start_date` and `description`) to the `Event/Show` page component.
11
+
In the example below, we will pass a single prop (`event`) which contains four attributes (`id`, `title`, `start_date` and `description`) to the `Event/Show` page component.
Copy file name to clipboardExpand all lines: v2/advanced/server-side-rendering.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -367,7 +367,7 @@ You will also need to set the `hydratable` compiler option to `true` in your `vi
367
367
368
368
## Deployment
369
369
370
-
When deploying your SSR enabled app to production, you'll need to build both the client-side (`app.js`) and server-side bundles (`ssr.js`), and then run the SSR server as a background process, typically using a process monitoring tool such as Supervisor.
370
+
When deploying your SSR enabled app to production, you'll need to build both the client-side (`app.js`) and server-side bundles (`ssr.js`), and then run the SSR server as a background process, typically using a process monitoring tool such as Supervisor.
Copy file name to clipboardExpand all lines: v2/the-basics/responses.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ title: Responses
6
6
7
7
Creating an Inertia response is simple. To get started, invoke the `Inertia::render()` method within your controller or route, providing both the name of the [JavaScript page component](/v2/the-basics/pages) that you wish to render, as well as any properties (data) for the page.
8
8
9
-
In the example below, we will pass a single property (`event`) which contains four attributes (`id`, `title`, `start_date` and `description`) to the `Event/Show` page component.
9
+
In the example below, we will pass a single property (`event`) which contains four attributes (`id`, `title`, `start_date` and `description`) to the `Event/Show` page component.
10
10
11
11
```php
12
12
use Inertia\Inertia;
@@ -83,7 +83,7 @@ Arrayable objects like Eloquent models and collections are automatically convert
83
83
84
84
When passing props to your components, you may want to create custom classes that can transform themselves into the appropriate data format. While Laravel's `Arrayable` interface simply converts objects to arrays, Inertia offers the more powerful `ProvidesInertiaProperty` interface for context-aware transformations.
85
85
86
-
This interface requires a `toInertiaProperty` method that receives a `PropertyContext`object containing the property key (`$context->key`), all props for the page (`$context->props`), and the request instance (`$context->request`).
86
+
This interface requires a `toInertiaProperty` method that receives a `PropertyContext`object containing the property key (`$context->key`), all props for the page (`$context->props`), and the request instance (`$context->request`).
In some situations you may want to group related props together for reusability across different pages. You can accomplish this by implementing the `ProvidesInertiaProperties` interface.
153
153
154
-
This interface requires a `toInertiaProperties` method that returns an array of key-value pairs. The method receives a `RenderContext` object containing the component name (`$context->component`) and request instance (`$context->request`).
154
+
This interface requires a `toInertiaProperties` method that returns an array of key-value pairs. The method receives a `RenderContext` object containing the component name (`$context->component`) and request instance (`$context->request`).
0 commit comments