Documentation
Rendering
Static output and request-time HTML are two adapters around the same TinyJS render function.
Both the build and serve commands call createTinySite().render(path):
import { createTinySite } from '@carl.fyi/tinyjs'
const tiny = await createTinySite()
const result = await tiny.render('/about')
// { html, status, headers, path, sourcePath }
Static builds
The build adapter writes result.html to the matching location under dist/. It also writes dist/tinyjs.json, preserving route status and header metadata that would otherwise be lost during compilation.
npx tinyjs build
Use --out to select another output directory and --root when the site is not in the current directory.
Dynamic rendering
The HTTP adapter sends the same HTML string with result.status and result.headers.
npx tinyjs serve
The production server compiles TSX once when it starts and renders content on every request. YAML and JSON page content is read for each render. Restart the server after changing TSX or site configuration.
The invariant
Because both adapters use the same renderer, a route has one HTML definition. Previewing dynamically does not create a second version of the site that can drift from the static build.