Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/jsx_stream/serialize.ts>renderString

JSX runtime for server-side only async streaming
Latest
function renderString
import { renderString } from "https://deno.land/x/jsx_stream@v0.2.0/serialize.ts";

Render the given JSX as a string.

This is an alternative to renderBody for situations that require just a string, or where streaming is not necessary or possible.

Prefer renderBody when rendering for a Response over this.

Examples

Example 1

console.log(renderString(
  <html>
    <body>
      <h1>Hello World</h1>
    </body>
  </html>
));

Parameters

node: JSX.Element

the JSX node

optional
options: Pick<RenderOptions, "tagHandlers">

rendering options

Returns

Promise<string>

A string of the serialized JSX