escText(s)h(tag, props, ...children)rawHtml(content)renderToString(node)tag(name)tagsServer-side rendering utilities.
import { h, tags, renderToString, rawHtml } from "@ztools.org/runtime/ssr";
Use ssr.js in Node/server build steps to produce deterministic HTML strings before shipping pages.
h(tag, props?, ...children)Creates SSR node objects.
const node = h("h1", null, "Hello SSR");
tag(name) / tagsTag helpers for SSR trees.
const { html, head, body, h1, p } = tags;
const page = html(
head(),
body(
h1("ztools SSR"),
p("Generated on server/build step")
)
);
renderToString(node)Renders SSR tree to HTML string.
const htmlText = "<!doctype html>\n" + renderToString(page);
rawHtml(html)Injects trusted raw HTML without escaping. Use carefully (only trusted content).
const page = h("div", null,
h("h2", null, "Embed trusted snippet"),
rawHtml("<p><strong>Trusted HTML</strong> injected as-is.</p>")
);