diff --git a/resources/js/Pages/server-side-rendering.jsx b/resources/js/Pages/server-side-rendering.jsx index ba3ffe5..3481dcc 100644 --- a/resources/js/Pages/server-side-rendering.jsx +++ b/resources/js/Pages/server-side-rendering.jsx @@ -279,6 +279,95 @@ export default function () { }, ]} /> +

Changing the Port

+

+ By default, the SSR server will run on port 13174.If you don't specify a port, Inertia will + continue to use this default. You might want to change this if the default port is already in use or if you need + to use multiple applications with SSR. +

+

+ You can change the port by passing a second argument to createServer: +

+ + createInertiaApp({ + // ... + }), + { port: 13714 }, + ) + `, + }, + { + name: 'React', + language: 'jsx', + code: dedent` + import { createInertiaApp } from '@inertiajs/react' + import createServer from '@inertiajs/react/server' + import ReactDOMServer from 'react-dom/server' + + createServer(page => + createInertiaApp({ + // ... + }), + { port: 13714 }, + ) + `, + }, + { + name: 'Svelte 4', + language: 'js', + code: dedent` + import { createInertiaApp } from '@inertiajs/svelte' + import createServer from '@inertiajs/svelte/server' + + createServer(page => + createInertiaApp({ + // ... + }), + { port: 13714 }, + ) + `, + }, + { + name: 'Svelte 5', + language: 'js', + code: dedent` + import { createInertiaApp } from '@inertiajs/svelte' + import createServer from '@inertiajs/svelte/server' + import { render } from 'svelte/server' + + createServer(page => + createInertiaApp({ + // ... + }), + { port: 13714 }, + ) + `, + }, + ]} + /> +

+ You can also combine options, for example: {'{ port: 13714, cluster: true }'}. +

+

+ After changing the port, update the SSR URL in your Inertia configuration by adding an{' '} + INERTIA_SSR_URL entry to your .env file: +

+

Setup Vite

Next, we need to update our Vite configuration to build our new ssr.js file. We can do this by