[]previous and next page

createServerHead

Creates an empty server head collector.

Creates an empty server head collector.

Import#

ts
import { createServerHead } from "@shadow-js/web/server";

Signature#

ts
function createServerHead(): ServerHead

Returns#

A collector to pass as the head option of renderToString, renderToStringAsync or renderToStream.

Examples#

ts
import { createComponent, Title } from "@shadow-js/web";
import { createServerHead, renderToString } from "@shadow-js/web/server";

function App() {
  return Title({ children: "Home" });
}

const head = createServerHead();
const html = renderToString(() => createComponent(App, {}), { head });
const page = `<!doctype html><head>${head.html()}</head><body>${html}</body>`;