variable / @typed/template

makeHydrateContext

Creates a hydration context starting from a root element.

This context allows the renderer to “attach” to existing DOM nodes (SSR output) instead of creating new ones.

Package version
1.0.0-beta.7
Category
Hydration context
Since
1.0.0

Import

import { makeHydrateContext } from "@typed/template";

Signatures

export declare const makeHydrateContext: (rootElement: HTMLElement) => Context.Context<never>;

Why

Hydration is an opt-in context derived from Typed’s versioned boundary markers. If rootElement is not a compatible hydration root, this function returns Context.empty() so DOM rendering performs a fresh construction; it does not promise to adopt arbitrary markup or sanitize it.

Ownership and lifetime

The returned Context only describes the starting cursor. The Scope running render owns adopted-node updates, listeners, subscriptions, and cleanup. Existing DOM identity is preserved only for successfully matched ranges.

Examples

import { makeHydrateContext } from "@typed/template/HydrateContext"

const services = makeHydrateContext(document.querySelector("#app")!)

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source