@reckona/mreact-server
v0.0.210
Published
Server rendering, streaming, hydration, and Flight primitives for mreact.
Maintainers
Readme
@reckona/mreact-server
@reckona/mreact-server contains server rendering primitives used by the mreact
compiler and router. It provides HTML sinks, streaming helpers, async
boundaries, hydration scripts, event hydration manifests, Flight serialization,
and response helpers.
Basic Usage
import { html, renderToString } from "@reckona/mreact-server";
const markup = await renderToString((sink) => {
sink.write("<main>Hello</main>");
});
const response = html(markup);Core APIs
createStringSink()writes HTML into a string sink.renderToString()renders through an HTML sink.renderToReadableStream()renders to aReadableStream.renderAsyncBoundary()andrenderOutOfOrderBoundary()support async SSR.renderHydrationBoundary()andrenderEventHydrationManifest()emit client hydration data.html()wraps rendered HTML in aResponse.
Streaming diagnostics
renderToReadableStream(render, { logAbortedDeferredErrors: true }) can log deferred task errors that arrive after the stream has already been aborted. The log is development-only, opt-in, and never writes the ignored error into the HTTP response body. onQueueStateChange is an opt-in diagnostic callback that reports the bytes, chunk count, and distinct backing buffer capacity retained by the local stream queues while a reader is slow.
Subpaths
@reckona/mreact-server/reorderapplies out-of-order SSR fragments in the browser.@reckona/mreact-server/flightexposes Flight and server action primitives.- Flight serialization emits repeated object values through a shared reference table, rejects cycles, and preserves shared identity when decoded by
@reckona/mreact-compat. @reckona/mreact-server/buffer-sinkexposes buffered streaming helpers.
Notes
Most applications use this package through @reckona/mreact-router.
