A Suspense-compatible variant of useStream for LangGraph Platform.
useSuspenseStream suspends the component while the initial thread
history is being fetched and throws errors to the nearest React Error
Boundary. During active streaming the component stays rendered and
isStreaming indicates whether tokens are arriving.
useSuspenseStream<
T = Record<string, unknown>,
Bag extends BagTemplate = BagTemplate
>(
options:| Name | Type | Description |
|---|---|---|
options* | UseSuspenseStreamOptions<T, InferBag<T, Bag>> |
<ErrorBoundary fallback={<ErrorDisplay />}>
<Suspense fallback={<Spinner />}>
<Chat />
</Suspense>
</ErrorBoundary>
function Chat() {
const { messages, submit, isStreaming } = useSuspenseStream({
assistantId: "agent",
apiUrl: "http://localhost:2024",
});
return <MessageList messages={messages} />;
}