Live HTML · In depth

exportStatic

Renders non-live decorated pages to deterministic directory indexes and content-addressed CSS. It is intended for docs, marketing pages, and static hosting.

Explain it like I’m five

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 it fits

When should I use it?

Use it when you need direct static export without defining a reusable site object and its shared layout policy.

A practical API pattern

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.

Read this article as Markdown

TypeScript
import path from 'node:path'
import { exportStatic, page } from 'redweb'

@page('/docs', { live: false, css: 'docs.css' })
class DocsPage {
  render() { return '<h1>Redweb docs</h1>' }
}

await exportStatic(DocsPage, {
  outDir: path.resolve('dist'),
  templateRoot: path.resolve('src/pages'),
})
  1. 1

    Page metadata determines output routes and page assets.

  2. 2

    Every page renders on the server into a staging destination.

  3. 3

    The returned paths let build tooling audit or publish exactly what was produced.

Configuration

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
Surface area

Methods and members

exportStatic(pageOrPages, options)

Returns frozen page and asset path lists after every page renders and its CSS is written.