Skip to content

Commit ae011d0

Browse files
committed
Add docs on clustering
1 parent c8f36c6 commit ae011d0

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

docs/guide/server-side-rendering.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,81 @@ createServer((page) =>
127127

128128
When creating this file, be sure to add anything that's missing from your regular initialization file that makes sense to run in SSR mode, such as plugins or custom mixins.
129129

130+
## Clustering
131+
132+
> Requires `@inertiajs/core` v2.0.7 or higher.
133+
134+
By default, the SSR server will run on a single thread. Clustering starts multiple Node servers on the same port, requests are then handled by each thread in a round-robin way.
135+
136+
You can enable clustering by passing a second argument to `createServer`:
137+
138+
:::tabs key:frameworks
139+
== Vue
140+
141+
```js
142+
import { createInertiaApp } from '@inertiajs/vue3'
143+
import createServer from '@inertiajs/vue3/server'
144+
import { renderToString } from '@vue/server-renderer'
145+
import { createSSRApp, h } from 'vue'
146+
147+
createServer(
148+
(page) =>
149+
createInertiaApp({
150+
// ...
151+
}),
152+
{ cluster: true },
153+
)
154+
```
155+
156+
== React
157+
158+
```js
159+
import { createInertiaApp } from '@inertiajs/react'
160+
import createServer from '@inertiajs/react/server'
161+
import ReactDOMServer from 'react-dom/server'
162+
163+
createServer(
164+
(page) =>
165+
createInertiaApp({
166+
// ...
167+
}),
168+
{ cluster: true },
169+
)
170+
```
171+
172+
== Svelte 4
173+
174+
```js
175+
import { createInertiaApp } from '@inertiajs/svelte'
176+
import createServer from '@inertiajs/svelte/server'
177+
178+
createServer(
179+
(page) =>
180+
createInertiaApp({
181+
// ...
182+
}),
183+
{ cluster: true },
184+
)
185+
```
186+
187+
== Svelte 5
188+
189+
```js
190+
import { createInertiaApp } from '@inertiajs/svelte'
191+
import createServer from '@inertiajs/svelte/server'
192+
import { render } from 'svelte/server'
193+
194+
createServer(
195+
(page) =>
196+
createInertiaApp({
197+
// ...
198+
}),
199+
{ cluster: true },
200+
)
201+
```
202+
203+
:::
204+
130205
## Setup Vite Ruby
131206

132207
Next, we need to update our Vite configuration to build our new `ssr.js` file. We can do this by adding a `ssrBuildEnabled` property to Ruby Vite plugin configuration in the `config/vite.json` file.

0 commit comments

Comments
 (0)