Skip to main content
Module

x/jsx_stream/mod.ts>renderBody

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

Render the given JSX as a stream suitable for passing into a Response body.

NOTE: this will not include a doctype, but there is a helper function to prepend that...

Examples

Example 1

import { renderBody } from "@http/jsx-stream";
import { html } from "@http/response/html";
import { prependDocType } from "@http/response/prepend-doctype";

Deno.serve(() => {
  return html(
    prependDocType(
      renderBody(
        <html>
          <body>
            <h1>Hello World</h1>
          </body>
        </html>
      )
    )
  );
});

Parameters

node: JSX.Element

the JSX node

optional
options: RenderOptions

rendering options

Returns

A ReadableStream of the serialized JSX