A complete site with shared defaults

Documentation for Redweb 0.13.3. Install that exact version when following these examples.

Define metadata, layout, CSS, caching, and asset export once, then keep each page focused on its content.

This pattern demonstrates one API area. Application-specific names, credentials, assets, and policies may need to be supplied. Complete starter recipes include all required application files.

tsx
import { defineSite } from 'redweb'

const site = defineSite({
  origin: 'https://example.com',
  css: 'site.css',
  head: { description: 'Product documentation', image: '/og.png' },
  cache: { maxAge: 300 },
  layout: content => <body><nav>Product</nav><main>{content}</main></body>,
})

@site.page('/docs', { head: { title: 'Documentation' } })
class DocsPage {
  render() { return <h1>Documentation</h1> }
}

await site.export(DocsPage, {
  outDir: 'dist',
  publicDir: 'public',
})

Notes and boundaries

  • Canonical URLs are derived from the route and origin.
  • Public assets and rendered pages are staged before output changes.
  • The generated site contains no Redweb browser runtime or WebSocket.