Documentation
¶
Overview ¶
Package ssr renders Svelte pages on the server by running the app's server bundle in embedded QuickJS VMs. It is pure Go: no cgo and no Node.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTimeout = errors.New("ssr: render timed out")
ErrTimeout is returned when a render exceeds the pool's timeout.
Functions ¶
This section is empty.
Types ¶
type Dev ¶
type Dev struct {
URL string // the Vite dev server, e.g. http://127.0.0.1:5174
Client *http.Client
}
Dev renders through the Vite dev server, so server rendering uses the same up-to-date modules as hot module replacement.
type Options ¶
type Options struct {
// Workers is the number of VMs, and so the number of concurrent
// renders. The default is GOMAXPROCS.
Workers int
// Timeout bounds a single render. The default is 5 seconds.
Timeout time.Duration
// MemoryLimit caps each VM's heap, in bytes. The default is 256 MiB.
MemoryLimit uintptr
// Logger receives console output from server-side code.
Logger *slog.Logger
}
Options configure a Pool.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool renders with a fixed number of reusable VMs. VMs are created on demand; a VM that times out or fails is discarded and replaced.
func NewPool ¶
NewPool compiles bundle, which must define globalThis.__tern_render, and returns a pool ready to render. It creates one VM up front so a broken bundle fails at startup rather than on the first request.