Skip to main content
Module

x/pagic/mod.ts>ReactDOMServer.renderToString

A static site generator powered by Deno + React
Latest
function ReactDOMServer.renderToString
import { ReactDOMServer } from "https://deno.land/x/pagic@v1.6.3/mod.ts";
const { renderToString } = ReactDOMServer;

Render a React element to its initial HTML. This should only be used on the server. React will return an HTML string. You can use this method to generate HTML on the server and send the markup down on the initial request for faster page loads and to allow search engines to crawl your pages for SEO purposes.

If you call ReactDOMClient.hydrateRoot() on a node that already has this server-rendered markup, React will preserve it and only attach event handlers, allowing you to have a very performant first-load experience.

Parameters

element: ReactElement

Returns

string