Server-side rendering
Server rendering runs your pages in Node with simple-dom: the HTML arrives complete, for crawlers, link previews and a fast first paint, and the browser hydrates it.
Setup
ssr.ts is the server-side twin of app.ts:
// The server-side twin of app.ts: `@inertiajs/vite` wraps this createInertiaApp() call so the Vite dev server
// (and `node bootstrap/ssr/app.js` in production) renders each first page load to HTML.
import { createInertiaApp, createOwner } from 'inertia-ember';
import AppLayout from './layouts/AppLayout.gts';
createInertiaApp({
serverHead: true,
layout: () => AppLayout,
// A function, so every page gets its own owner and no visitor sees another's service state.
owner: () => createOwner(import.meta.glob('./services/*.ts', { eager: true })),
});@inertiajs/vite wraps that call. In development, Vite renders each first page load. In production, vite build --ssr builds a server you run with node. With laravel-vite-plugin, name the input (ssr: 'resources/js/ssr.ts'); Laravel looks for the bundle at bootstrap/ssr/app.js, so the demo names its output file that way. Setting ssr.noExternal: true for the SSR build bundles every dependency, so the server runs without node_modules.
What runs on the server
While rendering on the server, modifiers don't run, router isn't started, polls and remembered state stay inert, and <WhenMounted> shows its fallback. <Head> tags go to the document head.
Hydration
By default, the server writes Glimmer's standard rehydration markers (<!--%+b:0%-->) using @glimmer/node's serializeBuilder, and the browser lazily loads @glimmer/runtime's rehydrationBuilder only when server-rendered markup is present. The browser attaches to those nodes instead of building the page again, so anything typed before the JavaScript loaded is kept. Where the browser renders something different from the server (<WhenMounted>, say), Glimmer replaces only that block.
Private Ember API
Ember's public renderComponent always builds the DOM from scratch, so hydration goes through the Renderer behind it, with Glimmer's serialize and rehydrate builders. FastBoot's _renderMode and vite-ember-ssr use the same mechanism, but it's private API. Unit tests pin it, and if an Ember release breaks it, the browser falls back to rendering from scratch, with a warning in the console.
Experimental fast SSR and hydration
For large server-rendered pages (lists, tables, dashboards), you can opt in to inertia-ember's direct-to-string SSR serializer and paired fast hydration builder. They live under separate subpaths so apps using Glimmer's default runtime bundle zero bytes of experimental code:
// resources/js/app.ts
import { createInertiaApp } from 'inertia-ember';
import { fastHydration } from 'inertia-ember/experimental';
createInertiaApp({
experimental: {
hydration: fastHydration(),
},
});// resources/js/ssr.ts
import { createInertiaApp } from 'inertia-ember';
import { fastSsr } from 'inertia-ember/experimental/server';
createInertiaApp({
experimental: {
ssr: fastSsr(),
},
});fastSsr()streams HTML straight to a string (nosimple-domtree) and omits per-block comment markers, keeping only a root pair (<!--%+i:0%-->…<!--%-i:0%-->).fastHydration()hydrates both compactfastSsr()markup and standard GlimmerserializeBuildermarkup without materializing BlinkAttrDOM nodes or removing thousands of per-block comments.- If
fastSsr()is enabled withoutfastHydration(), the browser safely falls back to a clean client render.
Every page of the demo is rendered on the server first. Turn JavaScript off and open it ↗ .