[]previous and next page

StreamContext

The context through which renderToStream lets a Suspense-like boundary defer its content: a boundary that is pending in the shell renders its fallback between <!--[b:ID--> and <!--]--> and defers a StreamBoundary to the sink.

The context through which renderToStream lets a Suspense-like boundary defer its content: a boundary that is pending in the shell renders its fallback between <!--[b:ID--> and <!--]--> and defers a StreamBoundary to the sink. Its value is null for every other render (the boundary then keeps its fallback).

Import#

ts
import { StreamContext } from "@shadow-js/web/extend";

Signature#

ts
const StreamContext: Context<StreamSink | null>

Examples#

ts
import { useContext } from "@shadow-js/core";
import { StreamContext } from "@shadow-js/web/extend";

function canStream(): boolean {
  // Inside a component rendered by renderToStream.
  return useContext(StreamContext) !== null;
}