Loading...
Loading...
Ossido renders your React on the server. How and when that render happens depends on the output mode - this page covers both modes and the machinery around them.
Set the default in ossido.config.ts with output ('server' or 'static'),
overridable per build with --server / --static (see
Configuration and The CLI):
server (SSR) - pages render per request in the standalone server binary.
Use it when a page depends on the request: auth, personalization, fresh data.static (SSG) - pages render once at build time to plain HTML you can host
anywhere. Best for content that's the same for everyone.Handlers, props, and the Rust/React boundary work identically in both; the only difference is when the render runs (see Static vs. Server).
#[static_paths]A static build needs to know every URL to pre-render. Static routes are
enumerated automatically; for dynamic routes ([param], [...slug]) you list
the values with #[static_paths]:
A [...slug] catch-all fills multiple segments at once with catchall:
The related StaticParams and SegmentValue types are re-exported from @ossido-labs/ossido
for building params programmatically. #[static_paths] only matters for static
builds - in server mode routes render on demand, so no enumeration is needed.
In server mode Ossido streams the HTML: the shell is sent first and the rest follows as it becomes ready, so the browser can start painting and fetching assets sooner instead of waiting for the whole page to render.
The SSR bundle is rendered as an ES module, so top-level await is supported,
convenient for module-level setup that must resolve before rendering.
Note that this behaviour is unpredictable in SSG mode, where the entire page is rendered in the browser. It is safer to use
awaitonly in SSR mode.
Server-side rendering runs on a dedicated, bounded pool of OS threads, each owning a warm V8 isolate and rendering one request at a time. Keeping renders off the async runtime means I/O keeps flowing while CPU-bound rendering proceeds in parallel across the pool.
Size it with ssr.renderThreads in the config or the OSSIDO_SSR_THREADS
environment variable at runtime; it defaults to the machine's available
parallelism (see Configuration).
See Why V8 for rendering for
why V8 backs the pool.
Back to Mental model & architecture · Configuration