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 trusted HTML strings or White Label JSX output and does not emulate browser events, focus, mounting, or animation frames.
import View from 'white-label-view/server';
const view = new View({
model,
template: data => `<main><h1>Hello, ${data.name}</h1></main>`
}).initialize();
const html = 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 JSX, trusted HTML strings, 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. Escape or sanitize untrusted dynamic values before they become trusted markup, or use the first-party JSX runtime where ordinary text and attribute values are escaped by default.
Third-party template engines remain responsible for their own escaping modes, raw-output features, helpers, plugins, and security configuration.