Skip to content

Per-route render modes

A render mode decides when a route's HTML is produced: at build time (static), per request (SSR), on the client (SPA), or revalidated on a schedule. A per-route switch lets a mostly static site keep one dynamic page without changing the whole app.

09 / 14Other featureOne of 7 features that do not affect first paint. Together they are worth 14 of the 28 points.

Labels across 23 frameworks

  • 1st-party19
  • Experimental0
  • Third-party0
  • Manual4
  • of 23

Overview

Quoted text uses the source document's own marks: ✅ means 1st-party, 🧪 means Experimental or Third-party, and 🔧 means Manual.

We tested this feature in 15 Books ports. 15 passed. Each framework's card below shows what its test saw. How we test labels.

Labels record what each framework's documentation says it provides. They are not performance measurements. How the labels are assigned.

How to enable it, by framework

One card per framework, in the same order on every feature page. Where a framework has no built-in support (Manual), a short example shows how to build it yourself.

Next

1st-party2 ptsOverview

Next documents stable per-route exports: without Cache Components, dynamic and revalidate (previous-model guide); with Cache Components, ensureStatic (v16.4.0+; this port sets ensureStatic = 'shell' in the root layout) plus 'use cache' boundaries (see section 4). This port enables Cache Components, where dynamic, revalidate, fetchCache, and dynamicParams are removed (route segment config).

Code example

With cacheComponents: true, a layout or page exports ensureStatic to say how much of the route must be static. The port sets 'shell' on the root layout, so the App Shell is prerendered and request-specific content streams in behind <Suspense>. 'navigation' would require the whole route to be static.

// app/layout.tsx
import { Suspense } from 'react'
// …
// Every route's App Shell (sidebar, header, Suspense fallbacks) must stay static;
// request-specific content streams in behind Suspense at prefetch/navigation time.
export const ensureStatic = 'shell'

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        <Suspense fallback={<HomeLinkFallback />}>
          <HomeLink />
        </Suspense>
        {children}
      </body>
    </html>
  )
}

Source: Next.js: ensureStatic

Nuxt

1st-party2 ptsOverview

routeRules: globs map to prerender, swr, isr, ssr: false, cache headers, redirects, and proxy rules.

export default defineNuxtConfig({
  routeRules: {
    '/admin/**': { ssr: false },
  },
})

Adapted from the rendering docs. This port uses a header-only cache rule on /** (needed for _payload.json prefetch) and disables caching on /api/**, shown in section 4.

SvelteKit

1st-party2 ptsOverview

Export prerender, ssr, and csr per route (page options).

export const prerender = true;
export const ssr = false;
export const csr = false;

From the page options docs (each is a separate option; combine as needed).

SolidStart

1st-party2 ptsOverview

Route prerendering is set under top-level nitro: { prerender: { routes, crawlLinks } } in v2/vite-plugin setups, and Nitro routeRules can set swr/cache per route (see the snippet in section 4); there is no per-route SSR/SPA switch. For the Solid 2 stack, see deployment (top-level nitro config) and choose a rendering mode (prerender-crawler).

export default defineConfig({
  plugins: [solidStart(), nitro()],
  nitro: {
    prerender: {
      routes: ["/", "/about"],
    },
  },
});

From the archived SolidStart v2 route pre-rendering docs (uses @solidjs/start, not this port's @solidjs/vite-plugin setup).

Per-route ssr: true | false | 'data-only' with a defaultSsr, plus a global SPA mode. Prerendering is configured in the plugin, and ISR is a headers pattern rather than a render mode.

export const startInstance = createStart(() => ({
  defaultSsr: false,
}))
export const Route = createFileRoute('/posts/$postId')({
  ssr: false,
  component: () => <div>This component is rendered on the client</div>,
})

From the selective SSR guide. The guide says 'data-only' keeps beforeLoad and loader on the server while skipping server rendering of the component.

The same per-route ssr: true | false | 'data-only', defaultSsr, and global SPA mode; the options match the React snippet.

import { createStart } from '@tanstack/solid-start'

export const startInstance = createStart(() => ({
  defaultSsr: false,
}))

From the Solid selective SSR guide; the per-route ssr: false example is the same as the React one.

Pracht

1st-party2 ptsOverview

Set render: "ssg" | "ssr" | "isg" | "spa" per route in src/routes.ts (rendering modes). Both routes in this port use isg.

route('/:id', './routes/book.tsx', {
  id: 'book',
  render: 'isg',
  revalidate: timeRevalidate(3600),
}),

From this repo's pracht-books/src/routes.ts (optimized branch; shell omitted).

Waku

1st-party2 ptsOverview

Export a getConfig that returns render: 'static' | 'dynamic' per page, layout, or slice (routing, slices).

export const getConfig = async () => {
  return {
    render: 'dynamic',
  } as const;
};

From this repo's waku-books/src/pages/[id].tsx (optimized branch).

Ember

Manual0 ptsOverview

SSR is app-wide in this port (emberSsr() from community vite-ember-ssr; official FastBoot is also app-wide). vite-ember-ssr can additionally prerender a listed set of routes at build time (emberSsg({ routes })), a community build step (React Router's equivalent first-party prerender list is what earns its ✅); no first-party per-route render mode is documented, so nothing to enable.

Code example

Choose the mode per path in the port's request handler. Server-render the routes that need it. For the rest, return the unrendered template: the same SPA shell the port's Netlify and Cloudflare deploys serve.

// server/handle-request.js
const CLIENT_ONLY = [/^\/account(\/|$)/]; // example: routes that skip SSR

export async function handleFetch(request, options = {}) {
  const url = new URL(request.url);
  // … /api/* handlers from the port …

  const template = await getTemplate();
  if (CLIENT_ONLY.some((re) => re.test(url.pathname))) {
    // SPA shell: app/entry.js boots the app in the browser
    return new Response(template, {
      headers: { 'content-type': 'text/html; charset=utf-8' },
    });
  }

  const emberApp = await getEmberApp();
  const rendered = await emberApp.renderRoute(`${url.pathname}${url.search}`, {
    settledTimeout: 8000,
  });
  return new Response(assembleHTML(template, rendered), {
    headers: { 'content-type': 'text/html; charset=utf-8' },
    status: rendered.statusCode,
  });
}

Astro

1st-party2 ptsOverview

Default static; export const prerender = false per page/endpoint for on-demand rendering; with output: 'server', prerender = true opts back in. On-demand pages need an adapter. (on-demand-rendering)

Code example

Pages prerender by default. export const prerender = false renders one page on demand; with output: 'server', prerender = true opts a page back into static output.

---
// src/pages/[id].astro
export const prerender = false; // render on each request (needs an adapter)

const { id } = Astro.params;
---
<h1>Book {id}</h1>

Source: Astro: On-demand rendering

React Router

1st-party2 ptsOverview

prerender (stable config) takes a per-URL list, so listed paths are static while the rest are server-rendered (ssr: true) or served from the SPA fallback (ssr: false); clientLoader skips server data per route. ssr itself is global, with no per-route export; ssr: "unstable_api-only" is experimental (v8.5.0). (rendering, pre-rendering, spa)

Code example

List the URLs to prerender at build time. Those paths become static HTML, and every other path is server-rendered because ssr stays true.

// react-router.config.ts
import type { Config } from '@react-router/dev/config'

export default {
  // Can be omitted - defaults to true
  ssr: true,
  prerender: ['/', '/blog', '/blog/popular-post'],
} satisfies Config

Source: React Router: Pre-Rendering

Qwik City

1st-party2 ptsOverview

SSG and SSR can be mixed per route; dynamic routes export onStaticGenerate. No per-route options beyond that documented; the Cloudflare Pages adapter has ssg include/exclude. (static-site-generation, cloudflare-pages)

Code example

A dynamic route that exports onStaticGenerate is prerendered for the params it returns. On Cloudflare Pages, the adapter's ssg.include and ssg.exclude choose which paths are static; the rest render on request.

// src/routes/product/[id]/index.tsx
import { component$ } from '@builder.io/qwik'
import { useLocation, type StaticGenerateHandler } from '@builder.io/qwik-city'

export default component$(() => <p>Product {useLocation().params.id}</p>)

export const onStaticGenerate: StaticGenerateHandler = async () => {
  return { params: [{ id: '1' }, { id: '2' }] }
}
// adapters/cloudflare-pages/vite.config.ts
plugins: [
  cloudflarePagesAdapter({
    ssg: { include: ['/*'], exclude: ['/shop/*'], origin: 'https://example.com' },
  }),
],

Source: Qwik: Static site generation, Qwik: Cloudflare Pages adapter

Angular (SSR)

1st-party2 ptsOverview

ServerRoute[] in app.routes.server.ts with RenderMode.Server/Client/Prerender; getPrerenderParams, fallback, per-route headers/status; outputMode: "static" for server-less builds. Stable since v20 per the roadmap (developer preview in v19); the guide itself carries no stability label. (ssr)

Code example

Each route picks a render mode in app.routes.server.ts: per-request SSR, build-time prerender, or client-only.

// src/app/app.routes.server.ts
import { inject } from '@angular/core';
import { RenderMode, PrerenderFallback, ServerRoute } from '@angular/ssr';

export const serverRoutes: ServerRoute[] = [
  { path: '', renderMode: RenderMode.Server },
  { path: 'about', renderMode: RenderMode.Prerender },
  { path: 'account', renderMode: RenderMode.Client },
  {
    path: 'book/:id',
    renderMode: RenderMode.Prerender,
    fallback: PrerenderFallback.Server,
    async getPrerenderParams() {
      const ids = await inject(BooksApi).topIds();
      return ids.map((id) => ({ id }));
    },
  },
  { path: '**', renderMode: RenderMode.Server, status: 404 },
];

Source: Angular: Server and hybrid rendering

Marko

Manual0 ptsOverview

Marko Run documents streaming SSR; the static adapter is app-wide and +meta.* is static metadata only. No per-route render-mode switch documented. (file-based-routing, adapters)

Code example

Every route still streams SSR. You tag a route with a mode in +meta.json, and the root middleware turns it into CDN Cache-Control. This adapts the port's +middleware.ts.

// src/routes/about/+meta.json   →  { "render": "static" }
// src/routes/+meta.json         →  { "render": "isr" }

// src/routes/+middleware.ts
const cacheControl: Record<string, string> = {
  static: "public, s-maxage=31536000",                // cached until redeploy
  isr: "public, s-maxage=60, stale-while-revalidate=86400",
};

export default Run.ALL(async (ctx, next) => {
  const res = await next();
  if (!res.headers.get("content-type")?.includes("text/html")) return res;
  const mode = (ctx.meta as { render?: string } | undefined)?.render;
  const headers = new Headers(res.headers);
  headers.set("Cache-Control", cacheControl[mode ?? ""] ?? "private, no-store"); // SSR
  return new Response(res.body, { status: res.status, statusText: res.statusText, headers });
});

Source: Marko Run file-based routing (+meta, +middleware)

Fresh

Manual0 ptsOverview

Pages render to HTML on the server; no per-route prerender/SPA/ISR option is documented (RouteConfig covers routeOverride, skipAppWrapper, skipInheritedLayouts, csp and methods; none selects a render mode). No first-party per-route render mode documented. (architecture, routing, file-routing)

Code example

Every route still renders on the server. You pick a mode per route with CDN Cache-Control headers in app middleware, adapting the port's main.ts middleware.

// main.ts
const modes: Record<string, string> = {
  "/about": "public, s-maxage=31536000",                    // "static": cached until redeploy
  "/": "public, s-maxage=60, stale-while-revalidate=86400", // "ISR": revalidate each minute
};

app.use(async (ctx) => {
  const res = await ctx.next();
  if (!res.headers.get("content-type")?.includes("text/html")) return res;
  const headers = new Headers(res.headers);
  headers.set("Cache-Control", modes[ctx.url.pathname] ?? "private, no-store"); // SSR
  return new Response(res.body, { status: res.status, statusText: res.statusText, headers });
});

app.fsRoutes();

Source: Fresh data fetching (response headers)

Analog

1st-party2 ptsOverview

SSR is the default; routeRules: { '/admin/**': { ssr: false } } in the Nitro config renders matching routes on the client only, and prerender.routes lists the routes built as static HTML. (server-side-rendering, static-site-generation)

Code example

Pages render on the server by default. routeRules in the Nitro plugin makes matching routes client-only, and prerender.routes builds the listed routes as static HTML.

// vite.config.ts
import analog from '@analogjs/platform';
import angular from '@analogjs/vite-plugin-angular';
import nitro from '@analogjs/vite-plugin-nitro';
import { defineConfig } from 'vite';

export default defineConfig(() => ({
  plugins: [
    analog({ prerender: { routes: ['/', '/about'] } }), // static HTML
    angular(),
    nitro({
      routeRules: {
        '/admin/**': { ssr: false }, // client-only
      },
    }),
  ],
}));

Source: Analog: Server-side rendering

Vike

1st-party2 ptsOverview

Per-page ssr: false (SPA) and prerender: true | false (SSG) in +config.js, inherited by every page under that directory; stream is per page too. (ssr, pre-rendering, stream)

Code example

Put ssr and prerender in a directory's +config. The setting applies to every page under that directory.

// pages/+config.ts (all pages: SSR, pre-rendered)
export default { prerender: true }

// pages/admin/+config.ts (admin pages: SPA, not pre-rendered)
export default { ssr: false, prerender: false }

// pages/search/+config.ts (search: SSR on each request, streamed)
export default { prerender: false, stream: true }

Source: Vike: ssr · Vike: Pre-rendering · Vike: stream

RedwoodSDK

1st-party2 ptsOverview

render(Document, routes, { ssr: false }) renders a group of routes on the client only, and { rscPayload: false } serves a group as static HTML with no hydration. No build-time prerender documented. (sdk-router)

Code example

Pass options as the third argument to render(). rscPayload: false serves a group as static HTML with no hydration, and ssr: false renders client components only in the browser.

// src/worker.tsx
import { defineApp } from "rwsdk/worker";
import { render, prefix } from "rwsdk/router";
import { ReactDocument, StaticDocument } from "@/app/Document";

export default defineApp([
  // Default: SSR with the RSC payload, so the page hydrates
  render(ReactDocument, [prefix("/app", appRoutes)]),
  // Static HTML, no hydration (StaticDocument has no client script)
  render(StaticDocument, [prefix("/docs", docsRoutes)], { rscPayload: false }),
  // Client components render only in the browser
  render(ReactDocument, [prefix("/spa", spaRoutes)], { ssr: false }),
]);

Source: RedwoodSDK: sdk/router

Remix 3

Manual0 ptsOverview

Routes render on the server per request. remix/spa runs a whole app as a client-rendered app; no per-route prerender or SPA switch is documented. (spa, request-handling)

Code example

Every route renders per request. To serve one page as static HTML, render it once at startup with renderToString() and return the stored string from that route.

// app/router.ts
import { renderToString } from "remix/component/server";
import { render } from "remix/middleware/render";
import { createHtmlResponse } from "remix/response/html";
import { createRouter } from "remix/router";
import { assets } from "./assets.ts";
import { AboutPage } from "./actions/about-page.tsx";

// rendered once, when the server starts
const aboutHtml = await renderToString(<AboutPage />);

export const router = createRouter({ middleware: [render({ assets })] });

router.get("/about", () =>
  createHtmlResponse(aboutHtml, { headers: { "Cache-Control": "public, max-age=3600" } }),
);
// all other routes: context.render(...) on each request

Source: Remix: Streaming UI with frames, render the response as a stream

Void (React)

1st-party2 ptsOverview

Per-page ssr = false (client-mounted shell, loader still runs), prerender = true | false, and revalidate = <seconds> exports in the .server.ts companion. App-wide output: "static" flips the prerender default, and island and Markdown pages are a further static mode. (overview, ssg, revalidation)

Code example

Pages render on each request by default. A page's .server.ts can turn off SSR or prerender it, and output: 'static' in void.config.ts prerenders every page unless it opts out.

// pages/account.server.ts: rendered in the browser only; the loader still runs on the server
export const ssr = false
// pages/about.server.ts: built to HTML (deploy-time on Cloudflare, build-time with output: 'static')
export const prerender = true

Source: Void: Pages routing · Void: Static sites · Void: Prerendering

Void (Vue)

1st-party2 ptsOverview

Per-page ssr = false (client-mounted shell, loader still runs), prerender = true | false, and revalidate = <seconds> exports in the .server.ts companion. App-wide output: "static" flips the prerender default, and island and Markdown pages are a further static mode. (overview, ssg, revalidation)

Code example

Pages render on each request by default. A page's .server.ts can turn off SSR or prerender it, and output: 'static' in void.config.ts prerenders every page unless it opts out.

// pages/account.server.ts: rendered in the browser only; the loader still runs on the server
export const ssr = false
// pages/about.server.ts: built to HTML (deploy-time on Cloudflare, build-time with output: 'static')
export const prerender = true

Source: Void: Pages routing · Void: Static sites · Void: Prerendering

Void (Svelte)

1st-party2 ptsOverview

Per-page ssr = false (client-mounted shell, loader still runs), prerender = true | false, and revalidate = <seconds> exports in the .server.ts companion. App-wide output: "static" flips the prerender default, and island and Markdown pages are a further static mode. (overview, ssg, revalidation)

Code example

Pages render on each request by default. A page's .server.ts can turn off SSR or prerender it, and output: 'static' in void.config.ts prerenders every page unless it opts out.

// pages/account.server.ts: rendered in the browser only; the loader still runs on the server
export const ssr = false
// pages/about.server.ts: built to HTML (deploy-time on Cloudflare, build-time with output: 'static')
export const prerender = true

Source: Void: Pages routing · Void: Static sites · Void: Prerendering

Void (Solid)

1st-party2 ptsOverview

Per-page ssr = false (client-mounted shell, loader still runs), prerender = true | false, and revalidate = <seconds> exports in the .server.ts companion. App-wide output: "static" flips the prerender default, and island and Markdown pages are a further static mode. (overview, ssg, revalidation)

Code example

Pages render on each request by default. A page's .server.ts can turn off SSR or prerender it, and output: 'static' in void.config.ts prerenders every page unless it opts out.

// pages/account.server.ts: rendered in the browser only; the loader still runs on the server
export const ssr = false
// pages/about.server.ts: built to HTML (deploy-time on Cloudflare, build-time with output: 'static')
export const prerender = true

Source: Void: Pages routing · Void: Static sites · Void: Prerendering

Gotchas

  • Static modes need an adapter that can serve prerendered output on the host you deploy to.