HtmlRenderer
Documentation for Redweb 0.13.3. Install that exact version when following these examples.
Lower-level rendering utility behind Live HTML. Most applications should use page(), start(), defineSite(), and exportStatic(); this surface supports advanced integrations and tooling.
Explain it like I’m five
HtmlRenderer is the machinery under the hood that turns a page object and its declared bindings into final markup.
When should I use it?
Use it for tooling or advanced integrations that genuinely need lower-level rendering control; normal applications should prefer pages, start, defineSite, or exportStatic.
Follow the example
This API pattern illustrates the named surface; it may require application-owned classes, credentials, or assets. Start from a complete recipe for a runnable application.
import { HtmlRenderer } from 'redweb'
const markup = HtmlRenderer.render(
'<h1>{{ title }}</h1>',
{ title: 'Reference' },
{ live: false },
)
const document = HtmlRenderer.document(markup, null, [], {
title: 'Reference',
})- A source template or fragment and page instance enter the renderer.
- Declared state, actions, views, and safe values are resolved under the render options.
- The caller receives final HTML suitable for its own response or build pipeline.
Methods and members
render(source, page, options?)
Renders declarative bindings and collection views against a page object.
document(markup, config?, stylesheets?, metadata?)
Wraps markup in a complete document and injects metadata, CSS, and optional live bootstrap.
template() / stylesheet()
Loads a validated page asset inside an explicit root.
statePayload()
Builds the text or trusted-HTML state payload used by live updates.
What should I watch for?
The lower-level API gives you more lifecycle responsibility. Preserve escaping, cancellation, ownership, and bounded concurrency rather than rebuilding them casually.