Inertia SSR

2 min read Updated 1 week ago

Inertia SSR

Server-side rendering (SSR) improves the initial load time and SEO of your Inertia.js applications by rendering pages on the server before sending them to the browser.

Prerequisites

Important: You must select a Node.js version in your application settings before adding the Inertia SSR service. SSR requires Node.js to render your Vue, React, or Svelte components on the server.

To configure Node.js:

  1. Navigate to your application's Settings tab
  2. Find the Node.js version section
  3. Select a Node.js version (20, 22, or 24)
  4. Save your settings and deploy your application

Adding Inertia SSR

  1. Go to your application's Services section
  2. Click Add service
  3. Select Custom service
  4. Select the Rendering category
  5. Choose Inertia SSR
  6. Optionally customize the SSR command
  7. Click Create service
  8. Deploy your application

How it works

The Inertia SSR service runs as a separate process alongside your main application. When a request comes in:

  1. Your Laravel application receives the request
  2. Instead of sending an empty HTML shell, Laravel calls the SSR server
  3. The SSR server renders your frontend component to HTML
  4. The fully rendered HTML is sent to the browser
  5. The browser hydrates the page, making it interactive

Environment variables

When you add the Inertia SSR service, the following environment variables are automatically configured:

  • INERTIA_SSR_ENABLED - Set to true to enable SSR
  • INERTIA_SSR_URL - The URL where the SSR server is running (http://127.0.0.1:13714)

These variables tell your Laravel application to use server-side rendering.

Custom SSR command

By default, the service runs:

php artisan inertia:start-ssr

You can customize this when adding the service if your application uses a different command.