exportStatic
Renders non-live decorated pages to deterministic directory indexes and content-addressed CSS. It is intended for docs, marketing pages, and static hosting.
The simple mental model
exportStatic is a printing press: give it pages, and it writes finished HTML and assets that any ordinary static host can serve.
When should I use it?
Use it when you need direct static export without defining a reusable site object and its shared layout policy.
Follow the example
This pattern explains the named API. Application classes, credentials, and assets may need to be supplied; use a complete recipe for a runnable starting point.
import { exportStatic, page } from 'redweb'
@page('/docs', { live: false })
class DocsPage {
render() { return <h1>Redweb docs</h1> }
}
await exportStatic(DocsPage, { outDir: 'dist' })- 1
Page metadata determines output routes and page assets.
- 2
exportStatic writes the requested output; your build owns any staging directory and atomic replacement.
- 3
The returned paths let build tooling audit or publish exactly what was produced.
Choices you can make
- outDir: required output directory; existing unrelated files are preserved
- templateRoot: optional explicit root for templates and CSS
- logger: optional framework logger or null
Methods and members
exportStatic(pageOrPages, options)
Returns frozen page and asset path lists after every page renders and its CSS is written.