API.md

@lazarv/react-server/rsc

Low-level RSC serialization helpers — serialize and deserialize React server component payloads directly. Most apps should not need these.

function fromBuffer<T = unknown, O = unknown>(value: Uint8Array, options?: O): Promise<T>;

Deserialize a buffer as a React component.

Parameters

Returns — A promise that resolves to the deserialized React component.

function fromStream<T = unknown, O = unknown>(stream: ReadableStream<Uint8Array>, options?: O): Promise<T>;

Deserialize a ReadableStream as a React component.

Parameters

Returns — A promise that resolves to the deserialized React component.

function toBuffer<T, O>(model: T, options?: O): Promise<Uint8Array>;

Serialize a React component into a buffer.

Parameters

Returns — A promise that resolves to a buffer containing the serialized component.

function toStream<T, O>(model: T, options?: O): Promise<ReadableStream<Uint8Array>>;

Serialize a React component to a ReadableStream.

Parameters

Returns — A promise that resolves to a ReadableStream containing the serialized component.