SSR
One render.js per app, all routes inside. Data comes from @[load] per render; prerender and ISR can retain the resulting HTML. Default is SPA/static + JSON; SSR is
optional.
@swelte/ssr-qjs is a separate install (npm install @swelte/ssr-qjs). Without it, swelte build skips the bridge pass and serves the static/SPA shell. import (swelte) from '@swelte/ssr-qjs' in vite.config.ts only works once the package is installed.- HTML nav
- load cascade
- QuickJS render
- hydrate
Request path
Browser GET / → Hand.before_request → swelte_page_props() (load cascade) → embedded QuickJS renderRoute(path, props) → HTML at <!--ssr-body--> + data-swelte-ssr="1". Default renderer fallback serves the SPA shell. Strict mode
rejects unexpected fallback with HTTP 500.
@[load] cascade
@[load] load_page(req SwelteRequest) !PageData { ... } // level 0
@[load] load_leaf(req SwelteRequest, parent PageData) !Leaf { ... }Root-first threading, one JSON encode at the edge. Throw → the nearest directory +error.svelte, with { status?, message? } props. Physical
ancestry includes route groups; a broken boundary falls back to its parent. See error boundaries.
Measured budgets
SSR guards (build errors)
QuickJS is pure-sync; load() stays in V. Browser-only SDK calls become render-time
throw-stubs; page state uses a request-local SSR shim. Guards inspect executable syntax, ignoring
prose, literal markup, CSS, comments and string contents. Template interpolation and markup
expressions are checked; deferred event handlers remain allowed.
State, isolation and strict rendering
SSR renders one nested Svelte tree with per-level load data, context and head output. Page state
is local to the request. Hydration uses the serialized initial envelope without refetching initial
data. Set SWELTE_SSR_STRICT=1 to reject unexpected renderer fallback; load watchdog timeouts return 504. Original QuickJS
exception details require SWELTE_SSR_DIAGNOSTICS=1; ordinary client responses stay
sanitized.
Packages and verification
The SSR bundle resolves installed Svelte/TypeScript/runes modules, package-private imports and
CommonJS dependencies. swelte ssr-check (via SWELTE_PLUGINS=@swelte/ssr-qjs) probes the sidecar, Hand backend and embedded
production binary when their artifacts exist, then shuts down its probe processes. swelte dev boots the development sidecar automatically when the adapter is installed;
production embeds QuickJS and needs no Node runtime.
The measurements above describe a small example workload, not a production capacity guarantee. The native dogfood measurement harness records startup, memory, streaming latency and concurrency with explicit workload limits.