DOM & HTML Output
TemplateResult is the source of truth. Use string or DOM projections only at system boundaries.
HTML string boundary
Use render(view) when an integration expects an HTML string.
tsx
import { render } from '@zoxon/mater'
const htmlString = render(<Button label="Save" />)DOM projections
Use DOM projections only in browser boundaries that need real nodes.
tsx
const view = <Button label="Save" />
view.html // SafeHtml, memoized
view.dom // fresh DocumentFragment
view.element // fresh Element, requires one root elementServer-side string rendering
On the server, keep the output as a string. Call render(view), then place the string into your HTTP response, template shell, or static file writer.
tsx
import { render } from '@zoxon/mater'
import { Button } from '@zoxon/lui/components/index.js'
const view = <Button label="Save" />
const htmlString = render(view)
return `<!doctype html><body>${htmlString}</body>`Router boundary pattern
The docs app parses the rendered string and swaps nodes at the route boundary.
ts
const doc = parser.parseFromString(render(renderFn()), 'text/html')
contentEl.replaceChildren(...Array.from(doc.body.childNodes))