Documentation for agents: an index at /llms.txt, every docs page in one file at /llms-full.txt, and Markdown for any docs page by adding .md to its URL.

Skip to Content
ensforgeReact

Server

Look up the server rendering helpers of @ensforge/react/server, which prefetch ENS reads on the server so the client hydrates with data.

Exports of @ensforge/react/server, for prefetching reads on the server.

Exports

dehydrate

Unstable

Prefetched reads of registry as plain data for <HydrationBoundary state={…}>.

function dehydrate(registry: AtomRegistry.AtomRegistry, options: { readonly streaming?: boolean | undefined } = {}): readonly Hydration.DehydratedAtom[]
  • Values are JSON (bigints and bytes are tagged), so they pass through server components and loaders. Entries carry no undefined fields, so the result can be returned directly from Next.js getServerSideProps and getStaticProps.
  • streaming: true also sends reads still loading, as promises that resolve on the client (React 19 server components, streaming SSR).
Streaming reads that are still loading
import { Actions } from "@ensforge/sdk"
import { HydrationBoundary } from "@ensforge/react"
import { dehydrate, prefetch } from "@ensforge/react/server"
import { AtomRegistry } from "effect/reactivity"

const registry = AtomRegistry.make()
void prefetch(registry, ens, Actions.indexer.getSubnames, { name: "ens.eth" })
const state = dehydrate(registry, { streaming: true })

prefetch

Unstable

Runs a read on the server into registry, so dehydrate can send its result to the client.

function prefetch<action extends Action>(registry: AtomRegistry.AtomRegistry, client: Ensforge.Client, action: action, options: ActionOptions<action>, freshness?: Freshness): Promise<void>

Use in server components, loaders and getServerSideProps/getStaticProps for the reads a page renders first. Reads that are not prefetched render as loading on the server and run in the browser.

  • Resolves once the read settles; a failed read is not sent, so the browser retries it.
  • Do not await it when streaming (dehydrate(registry, { streaming: true })): pending reads then stream to the client as they resolve.
  • Use a new registry per request.
Next.js App Router
import { Actions } from "@ensforge/sdk"
import { HydrationBoundary } from "@ensforge/react"
import { dehydrate, prefetch } from "@ensforge/react/server"
import { AtomRegistry } from "effect/reactivity"

export default async function Page({ params }: { params: { name: string } }) {
  const registry = AtomRegistry.make()
  await prefetch(registry, ens, Actions.name.get, { name: params.name })
  return <HydrationBoundary state={dehydrate(registry)}>{params.name}</HydrationBoundary>
}

Was this page helpful?