Inertia SSR

2 min read Updated 5 months 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.

Frequently asked questions

What is the command to start the Inertia SSR server?

Run `php artisan inertia:start-ssr`. This starts a long-running Node.js process that renders your Vue or React components server-side before hydrating in the browser.

What does the INERTIA_SSR_ENABLED environment variable do?

Setting `INERTIA_SSR_ENABLED=true` tells Inertia to render initial page loads on the server before sending HTML to the browser. Without it, Inertia falls back to client-side rendering only.

What port does the Inertia SSR server listen on?

By default, Inertia SSR listens on port 13714. The Laravel app talks to it on this port to request server-rendered HTML. Configure it via `config/inertia.php` if needed.

When should I enable SSR for an Inertia.js application?

Enable SSR when you need search engine indexing of dynamic content, faster perceived first-paint, or social-media link previews. Skip it for purely authenticated dashboards where neither SEO nor first-paint matters.