Page lifecycle

HTML rendering, navigation and refresh share a guarded V load cascade. Middleware runs before handlers, loads, actions, streams and socket takeover.

Loads and component data

Root-first loads retain each wrapper's data. Default mode uses flat props. With swelte.compat: 'sveltekit', ancestor objects merge into each level's data, deeper keys win, and components receive data/form props. Synchronous universal loads transform data in SSR and the browser; native I/O stays in V.

SSR and hydration

Each render gets isolated page state. A single Svelte tree preserves wrapper context and head output. Public initial state is escaped into an inert JSON element; locals and secrets are excluded. Hydration reuses that envelope and the same level props. The canonical reactive object is #app/state; compatibility mode exposes it through $app/state. Legacy stores remain available.

Navigation and refresh

Navigation loads before committing UI and preserves query strings, hashes and history. Redirects and errors are explicit outcomes. Stale results cannot replace a newer navigation. invalidateAll() awaits a load refresh and committed props; tagged invalidation refreshes affected active loads. Refresh preserves mounted component state when route and wrapper identities remain unchanged.

Native lifecycle and reporting

Startup hooks finish before dependent plugin jobs begin. Signal shutdown stops admission, drains loads/jobs/streams and runs bounded cleanup. Optional report hooks receive request identifiers and server-side lifecycle/error events; reporter failures are isolated from responses.

Prerendering and limits

Prerendering supports grouped/dynamic entries, encoded parameters, inherited opt-outs and canonical/head output. Redirects, error pages and fallback shells are excluded. Hydrated state uses the hosting URL. Nested error boundaries select the nearest physical ancestor, retain wrappers above that boundary and fall back to a parent if rendering fails.

Caching, assets and durable work

Native ISR serves public cached HTML during background regeneration and replaces it atomically. Build-time images resize PNG/JPEG sources into WebP variants. The offline outbox persists explicit mutations with retries and Background Sync. Durable jobs persist schedules and coordinate processes sharing one SQLite file.