LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Stream
  • Overview
  • Getting started
  • useStream
  • Selectors
  • Interrupts & headless tools
  • Subagents & subgraphs
  • Fork & edit from a checkpoint
  • Submission queue
  • Multimodal media
  • Transports
  • Suspense
  • StreamProvider & context
  • Type safety
  • Migrating to v1
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
  • Stream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemoteStream
OverviewGetting starteduseStreamSelectorsInterrupts & headless toolsSubagents & subgraphsFork & edit from a checkpointSubmission queueMultimodal mediaTransportsSuspenseStreamProvider & contextType safetyMigrating to v1
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServerStream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/reactuseStream
Function●Since v0.2

useStream

Copy
useStream<
  T = Record<string, unknown>,
  InterruptType = unknown,
  ConfigurableType extends object

Used in Docs

  • AI Elements
  • assistant-ui
  • Branching chat
  • Generative UI
  • Going to production
(7 more not shown)
View source on GitHub
=
Record
<
string
,
unknown
>
>
(
options
:
UseStreamOptions
<
InferStateType
<
T
>
>
)
:
UseStreamReturn
<
T
,
InterruptType
,
ConfigurableType
>

Parameters

NameTypeDescription
options*UseStreamOptions<InferStateType<T>>

React binding for the v2-native stream runtime.

useStream exposes three always-on projections (values / messages / toolCalls) at the thread root plus cheap discovery maps for subagents / subgraphs. Scoped views of subagents, subgraphs, or any namespaced projection are surfaced via the companion selector hooks:

const stream = useStream({ assistantId: "deep-agent" });

// Root messages — always on, already class instances.
stream.messages.map((m) => <Bubble key={m.id} msg={m} />);

// Subagent view — mount = subscribe, unmount = unsubscribe.
function SubagentCard({ subagent }) {
  const messages = useMessages(stream, subagent);
  const toolCalls = useToolCalls(stream, subagent);
  return <>{messages.map(...)}</>;
}

The first generic accepts either a plain state type (useStream<MyState>()) or a compiled graph type (useStream<typeof agent>()); in the latter case the state shape is unwrapped from the graph via InferStateType, so stream.values is always typed as the state, never as the graph class itself.