Rendering & SSR

getHydrationWriter

The keyed server-to-client value channel of the render the caller belongs to — found through the caller's owner, else (no owner) through the request scope when exactly one render is open for that request. undefined outside any render and on the client. Never another request's render.

Capture it where the render is known (component setup) to write from IO later. A write is not gated on <NoHydration>: read isHydratable() where the value is produced to decide. Read the value on the client with takeHydrationValue(key).


Import

import { getHydrationWriter } from "@solidjs/web";

Type signature

function getHydrationWriter(): HydrationWriter | undefined;

Examples

const writer = getHydrationWriter();
if (writer && isHydratable()) writer.write("sq:" + hash, data);

Learn more


HydrationWriter

A render's keyed server-to-client value channel (getHydrationWriter).

interface HydrationWriter {
readonly async: boolean;
write(
key: string,
value: unknown,
options?: { deferStream?: boolean }
): boolean;
}

async

  • Type: boolean

Whether the render takes promises and async iterables (renderToStream). renderToString takes synchronous values only; write throws on an async one.

write

  • Type: boolean

Serializes value for the client under key, readable there with takeHydrationValue(key). Returns false without writing when key was already written by this render (the first write wins) or the render no longer takes values (a finished renderToString, a completed stream). deferStream holds the shell until a promise settles. Prefix keys with the library's own namespace ("sq:"); Solid's own entries are keyed by hydration id.

Last updated: 9/30/26, 8:28 PMEdit this pageReport an issue with this page