Server rendering guide

Server-side rendering without a component framework

Render TypeScript templates to HTML on the server without a component framework or DOM globals. White Label View keeps the rendering contract explicit and portable.

Use the server entrypoint

white-label-view/server uses the same model and template concepts as Browser View but stores rendered HTML instead of mounting DOM nodes.

It accepts tagged White Label markup or compatible trusted HTML strings and does not emulate browser events, focus, mounting, or animation frames.

import View from 'white-label-view/server';
import {html} from 'white-label-view/html';

const view = new View({
    model,
    template: data => html`<main><h1>Hello, ${data.name}</h1></main>`
}).initialize();

const htmlOutput = view.toString();

Scope mutable state to the request

Server applications should create request-specific Model and View instances when state can differ between requests. Sharing mutable rendering state across concurrent requests can leak one request into another.

Destroying the View releases model subscriptions, child ownership, and stored output when the request lifecycle is complete.

Keep portable rendering concepts portable

The same application can choose first-party tagged HTML, compatible trusted HTML strings, DOM output in the browser, or an application-owned template engine without changing View into a framework-specific adapter.

Browser-only behavior stays in Browser View while server rendering remains free of window and document globals.

Treat HTML strings as a trust boundary

White Label does not sanitize caller-provided HTML strings. Prefer white-label-view/html when you want escaped interpolations and an explicit unsafeHTML() boundary, or escape and sanitize application-owned renderer output according to that renderer’s contract.

Third-party template engines remain responsible for their own escaping modes, raw-output features, helpers, plugins, URL or CSS validation, and security configuration.