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/reactAnyStream
Type●Since v1.0

AnyStream

Erased stream handle useful as a parameter type for helpers and wrapper components that pass a stream through to selector hooks (useMessages, useChannel, …) without reading values directly.

Any fully-typed UseStreamReturn<T, I, C> is assignable to AnyStream. Widening the three generic slots to any is not enough on its own: members whose types are computed from T in covariant positions don't collapse to a top type under any. In particular toolCalls: InferToolCalls<any>[] resolves to AssembledToolCall<string, …, never>[] — the never output slot is narrower than a concrete handle's AssembledToolCall<…, unknown>[], so the concrete handle fails to assign and every useToolCalls(stream) call would need an as AnyStream cast. values / ~stateType (computed via InferStateType<any>) have the same hazard. We override those members with their widest forms so the erased handle is a true supertype of every concrete UseStreamReturn.

Copy
AnyStream: Omit<UseStreamReturn<any, any, any>, "toolCalls" | "values" | "~stateType">  __type

Example

Copy
function SubgraphCard({ stream, subgraph }: {
  stream: AnyStream;
  subgraph: SubgraphDiscoverySnapshot;
}) {
  const messages = useMessages(stream, subgraph);
  return <Feed messages={messages} />;
}
View source on GitHub