Prerendering and Caching
SvelteKit has no ISR-style cache to switch on. Instead you compose rendering decisions per route, and the result covers everything Next.js ISR does - with more explicit control over which parts are static.
Page options
Export flags from +page.js / +page.server.js (or a shared +layout.js for a whole section). Child routes override parents; the root layout sets app-wide defaults:
// src/routes/+layout.js - prerender everything by default
export const prerender = true;
// src/routes/daily/[date]/[group]/+page.js - opt out for live pages
export const prerender = false;
| Option | Controls |
|---|---|
prerender | build-time HTML generation |
ssr | server-render at all (default true) |
csr | hydrate + client router (default true) |
The mix-and-match is the point: prerender the marketing pages, server-render the dynamic ones for SEO, and turn an admin section into an SPA with csr-only rendering.
The prerender = 'auto' case
The interesting value is not true or false but 'auto': prerender the route and keep it in the SSR manifest. A /daily/[group] route can prerender its recent, popular pages while the long tail renders on demand - one route, both behaviors, no edge-function wrangling.
The prerenderer starts at the root and follows <a> links, so most sites need no explicit page list. For dynamic routes it cannot discover (no inbound link yet), export an entries function:
// src/routes/daily/[date]/+page.js
export const entries = () => {
// e.g. the last 30 days from your API
return dates.map((date) => ({ date }));
};
Gotcha: prerendered pages are build artifacts. If the data behind them changes hourly, build-time generation alone is the wrong tool - combine with on-demand SSR (below) or rebuild-on-deploy.
The caching story (vs Next.js ISR)
| Need | SvelteKit answer |
|---|---|
| Static content | prerender = true, output shipped by the adapter or adapter-static |
| Popular-but-dynamic pages | prerender = 'auto' + entries |
| Long tail | on-demand SSR (default behavior) |
| Fine-grained cached data | remote functions: query() (cached) and prerender() (build-time), see Remote Functions |
| CDN/browser caching | explicit Cache-Control headers via a handle hook or your proxy; no framework TTL layer to configure |
There is no tag-based invalidation webhook equivalent. The SvelteKit-shaped equivalent of theok’s POST /api/revalidate is: rebuild on deploy for prerendered content, query().refresh() for remote-function data, and short max-age windows for everything in between.
Read next
- Remote Functions - the experimental query/form/prerender primitives
- Loading Data - the stable load-function model