Skip to main content
Module

x/fresh/src/server/render.tsx>render

The next-gen web framework.
Extremely Popular
Go to Latest
function render
import { render } from "https://deno.land/x/fresh@1.0.2/src/server/render.tsx";

This function renders out a page. Rendering is asynchronous, and streaming. Rendering happens in multiple steps, because of the need to handle suspense.

  1. The page's vnode tree is constructed.
  2. The page's vnode tree is passed to the renderer.
  • If the rendering throws a promise, the promise is awaited before continuing. This allows the renderer to handle async hooks.
  • Once the rendering throws no more promises, the initial render is complete and a body string is returned.
  • During rendering, every time a <Suspense> is rendered, it, and it's attached children are recorded for later rendering.
  1. Once the inital render is complete, the body string is fitted into the HTML wrapper template.
  2. The full inital render in the template is yielded to be sent to the client.
  3. Now the suspended vnodes are rendered. These are individually rendered like described in step 2 above. Once each node is done rendering, it wrapped in some boilderplate HTML, and suffixed with some JS, and then sent to the client. On the client the HTML will be slotted into the DOM at the location of the original <Suspense> node.

Returns

Promise<[string, ContentSecurityPolicy | undefined]>