Static React renderer. Walks a component tree, emits deterministic HTML with Tailwind class strings and data-class token maps. Server-only; hydration-free. Downstream vSsg ingests the data-class attributes for semantic CSS rewrite.
npm install @booga/vrendererPeer dependency: react ^18.
import { render, renderToFile } from "@booga/vrenderer";
import { createElement } from "react";
const html = render(createElement("div", { p: 2, variant: "primary" }, "hello"));
// → <div class="p-2 variant-primary" data-class="p-2 variant-primary">hello</div>
await renderToFile(tree, "./out/index.html");Synchronous. Throws if called in a browser environment (use allowBrowser: true in tests).
Calls render(), writes result to path as UTF-8.
| Option | Default | Description |
|---|---|---|
pretty |
false |
Indent output with two spaces per nesting level |
sortAttrs |
true |
Sort HTML attributes lexicographically |
emitDataClass |
true |
Emit data-class attribute from DSL token props |
allowBrowser |
false |
Suppress server-only guard (testing only) |
Props from @booga/vdsl (p, m, variant, size, bg, …) are partitioned before emit:
- removed from the raw HTML attribute set
- compiled to a
classstring viaresolveClasses - mirrored to
data-classviaextractDataClass
className merges with any DSL-derived class into a single class attribute.
- Void tags (
img,br,input, …) self-close - Event handlers (
on*) stripped keyandrefstrippedstyleobjects serialized to inline CSSdangerouslySetInnerHTML.__htmlemitted raw- Text content and attribute values HTML-escaped
MIT © 2026 bvasilenko