method IViewEngine.render
Since 0.6.0
IViewEngine.render<P>(
component: Component<P>,
props: P
): string | Promise<string>

Renders a view component with the given props to an HTML string.

Interpolations are escaped by the RENDERING RUNTIME — the JSX runtime and the html tagged template both escape — and a component opts out with hono's own raw(), never with engine-level configuration.

The escaping is therefore a property of how a component is WRITTEN, not a guarantee this port makes. A plain (props) => string component is a valid Component and its output is returned unchanged: correct for a by-name engine whose compiled template has already escaped its own interpolations, and an XSS hole for a hand-written template literal such as (p) => `<p>${p.name}</p>` . Prefer JSX or the html tag; reach for a plain string only when the producer already escaped.

Type Parameters

The component's props bag

Parameters

component: Component<P>

The view component to render

props: P

The props passed to the component

Return Type

string | Promise<string>

The rendered HTML, buffering before send — never a stream

Throws

Error

Implementations refuse a tree holding a pending <Suspense> boundary by name (buffered rendering would serve only the fallback forever) and wrap a component that throws

Usage

import { type IViewEngine } from "common/src/index.ts";