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
  • provideStream & context
  • Type safety
  • Migrating to v1
LangGraph SDK
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Server
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

Chat LangChain

What can I help with?

Enter to send·Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemoteStream
OverviewGetting starteduseStreamSelectorsInterrupts & headless toolsSubagents & subgraphsFork & edit from a checkpointSubmission queueMultimodal mediaTransportsSuspenseprovideStream & contextType safetyMigrating to v1
LangGraph SDK
ClientAuthReactLoggingReact UiServer
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
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/vue

@langchain/vue

Description

@langchain/vue

Vue SDK for building AI-powered applications with Deep Agents, LangChain and LangGraph.

The package ships a Composition-API–first binding built on top of the v2 streaming protocol. useStream returns a small, always-on root handle (values, messages, isLoading, error, …) and pushes anything namespaced (subagents, subgraphs, media, submission queue, per-message metadata) behind ref-counted use* selectors so components only pay for the data they actually consume.

Upgrading from 0.x? See docs/v1-migration.md for the complete matrix of option, return-shape, and transport changes.

Highlights

  • v2-native streaming protocol. Session-based transport with automatic re-attach on remount — no reconnectOnMount / joinStream dance.
  • Composition-API first. Everything is a ShallowRef / ComputedRef, auto-disposed via onScopeDispose when the scope unmounts.
  • Selector-based subscriptions. Namespaced data (subagents, subgraphs, media) streams only when a component actually mounts the matching selector composable, and releases on unmount.
  • Discriminated transports. Hosted Agent Server and custom adapters are two arms of a single typed union — mixing them is a compile-time error.
  • Agent-brand type inference. useStream<typeof agent>() unwraps state, tool calls, and subagent state maps from an agent brand.
  • Multimodal media streams. Built-in assembly for audio, images, video, and files, with ready-to-use <img> / <audio> / <video> players.
  • <Suspense> friendly. hydrationPromise lets you gate async setup() on initial hydration.

Installation

npm install @langchain/vue @langchain/core

Peer dependencies: vue (^3.4.0), @langchain/core (^1.0.1).

Quick start

<script setup lang="ts">
import { useStream } from "@langchain/vue";

const stream = useStream({
  assistantId: "agent",
  apiUrl: "http://localhost:2024",
});

function onSubmit() {
  void stream.submit({ messages: [{ type: "human", content: "Hello!" }] });
}
</script>

<template>
  <div>
    <div v-for="(msg, i) in stream.messages" :key="msg.id ?? i">
      {{ typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content) }}
    </div>

    <button :disabled="stream.isLoading" @click="onSubmit">
      Send
    </button>
  </div>
</template>

Reactive fields on the handle are Vue refs (ShallowRef / ComputedRef). In <script setup>, read them with .value: stream.messages.value, stream.isLoading.value. In <template>, Vue auto-unwraps refs, so prefer the shorter stream.messages / stream.isLoading form.

Documentation

In-depth guides live in docs/:

  • API reference — useStream options and return shape.
  • Selectors — ref-counted readers for namespaced / scoped data.
  • Transports — SSE, WebSocket, and custom AgentServerAdapter implementations.
  • Custom transports — implementing AgentServerAdapter against your own backend, with a worked walkthrough of examples/ui-react-transport.
  • Interrupts & headless tools — pausing a run, responding to interrupts, registering browser-side tools.
  • Forking from a message — edit / retry flows with useMessageMetadata + submit({ forkFrom }).
  • Submission queue — inspecting and cancelling enqueued submits.
  • Subagents & subgraphs — rendering per-subagent messages, tool calls, and state via scoped selectors.
  • Multimodal media — audio / image / video / file streams with built-in players.
  • Sharing a stream — provideStream, useStreamContext, and the LangChainPlugin app-level defaults.
  • Suspense-style hydration — gating async setup() on hydrationPromise.
  • Type safety — brand inference, generics, and the exported helper types.
  • Testing — mounting components with mock streams or real dev servers.
  • Migrating from 0.x — full diff of options, return shape, and transport classes.

Playground

For complete end-to-end examples with full agentic UIs, visit the LangChain UI Playground.

License

MIT

Classes

Class

HttpAgentServerAdapter

Public v1 name for TransportAdapter plus optional high-level capabilities. Renamed to reflect that this interface now denotes the full agent-server protocol contract (not merely wire transport): any o

Class

MediaAssemblyError

Typed error thrown through media.stream / rejected from media.blob / media.objectURL when a handle fails before its message completes. Carries the bytes accumulated up to the failure point on `p

Functions

Function

executeHeadlessTool

Function

filterOutHeadlessToolInterrupts

Strip headless-tool interrupts from a user-facing interrupt list.

Function

findHeadlessTool

Function

flushPendingHeadlessToolInterrupts

Execute and resume all newly seen headless-tool interrupts from a values payload. Callers own handledIds and should clear it when the thread changes.

Function

handleHeadlessToolInterrupt

Function

headlessToolResumeCommand

Function

isHeadlessToolInterrupt

Function

parseHeadlessToolInterruptPayload

Parses a headless-tool interrupt value from the graph. Accepts both toolCall (LangChain JS) and tool_call (Python / JSON snake_case).

Function

provideStream

Creates a shared useStream instance and provides it to all descendant components via Vue's provide/inject.

Call this in a parent component's <script setup> to make the stream available to chi

Function

useAudio

Subscribe to a scoped audio-media stream. Each handle is yielded on its first matching content-block-start, exposes .partialBytes for live access, settles .blob / .objectURL / .transcript on

Function

useAudioPlayer

Progressive audio playback for AudioMedia handles with a uniform surface across PCM (streamed) and container (HTMLAudioElement) strategies.

See useAudioPlayer in the React binding for the full beha

Function

useChannel

Function

useChannelEffect

Side-effect counterpart to useChannel. Instead of returning a reactive buffer, it invokes onEvent once per event for as long as the calling scope is alive — the idiomatic place for analytics, loggin

Function

useExtension

Subscribe to a custom:<name> stream extension — the most-recent payload emitted by the transformer, scoped to the target namespace.

Returns only the latest value and resumes across serial runs, so

Function

useFiles

Subscribe to a scoped file-media stream. Pair with useMediaURL for an <a download href> target.

Function

useImages

Subscribe to a scoped image-media stream. Pair with useMediaURL for <img src>.

Function

useMediaURL

Resolve the lazy MediaBase.objectURL promise into a reactive string suitable for <audio src>, <img src>, <video src>, or <a download href>. Returns undefined until the URL is available.

Lif

Function

useMessageMetadata

Read metadata recorded for a specific message id — today exposes parentCheckpointId, the checkpoint the message was first seen on. Designed for fork / edit flows:

const meta = useMessageMetad
Function

useMessages

Subscribe to a scoped messages stream.

Contract:

  • At the root (no target) this returns stream.messages — the always-on root projection; no extra subscription is opened.
  • For any non-root
Function

useProjection

Vue primitive that composes ChannelRegistry.acquire with Vue's reactivity system.

Contract (mirrors the React useProjection hook but adapted to Vue's setup + onScopeDispose lifecycle):

  • On `
Function

useStream

Vue Composition API binding for the v2-native stream runtime.

Returns a handle whose projections are Vue refs so templates auto-unwrap and scripts can feed them into computed/watch. Scoped views

Function

useStreamContext

Accesses the shared stream instance from the nearest ancestor that called provideStream().

Throws if no ancestor has provided a stream.

Function

useSubmissionQueue

Function

useToolCalls

Subscribe to a scoped tools (tool-call) stream. Same target and lifecycle rules as useMessages; at the root this returns stream.toolCalls directly.

Function

useValues

Subscribe to a scoped values stream — the most recent state payload for a namespace. At the root returns stream.values.

Typing:

  • Root (useValues(stream)): returns the StateType declared
Function

useVideo

Subscribe to a scoped video-media stream. Pair with useMediaURL for <video src>.

Function

useVideoPlayer

Bind a VideoMedia handle to a caller-owned <video> element.

Vue idioms:

  • videoRef accepts a raw HTMLVideoElement, a Ref<...>, or a getter. Pair with <video ref="video" /> in the templa

Interfaces

Types

Interface

AgentServerAdapter

Public v1 name for TransportAdapter plus optional high-level capabilities. Renamed to reflect that this interface now denotes the full agent-server protocol contract (not merely wire transport): any o

Interface

AssembledToolCall

Reactive tool handle for framework bindings (stream.toolCalls, useToolCalls, injectToolCalls).

status, error, and output are plain values that the assembler updates in place as tool events arri

Interface

AudioMedia

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Interface

AudioPlayerHandle

Player controls + live state returned by useAudioPlayer.

Live state is exposed as Vue refs so templates auto-unwrap; all imperative controls are plain functions.

Interface

FileMedia

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Interface

FlushPendingHeadlessToolInterruptsOptions

Interface

HeadlessToolImplementation

Client-side implementation returned by headlessTool.implement(...).

Interface

HeadlessToolInterrupt

Represents a headless tool interrupt payload emitted by LangChain's schema-only tool({ ... }) overload.

Servers may serialize the nested tool call as toolCall (JS) or tool_call (Python). Use pa

Interface

HttpAgentServerAdapterOptions

Interface

ImageMedia

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Interface

LangChainPluginOptions

Configuration options for the LangChain Vue plugin. These provide default values that useStream will pick up automatically.

Interface

MediaBase

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Interface

MessageMetadata

Metadata tracked per message id. Surfaced to applications via useMessageMetadata(stream, messageId).

Interface

StreamStopOptions

Options for StreamController.stop / framework stop().

Interface

StreamSubmitOptions

Interface

SubagentDiscoverySnapshot

Lightweight discovery record for a subagent running inside the thread.

Populated eagerly from the root subscription (tools + lifecycle channels). Content projections (messages, toolCalls, cus

Interface

SubgraphDiscoverySnapshot

Lightweight discovery record for a subgraph running inside the thread.

Interface

SubmissionQueueEntry

A single queued submission.

Interface

ThreadStream

High-level wrapper around a protocol connection to a specific thread.

In the thread-centric protocol, threads are durable (backed by checkpoints) and connections are ephemeral. A ThreadStream is th

Interface

ToolEvent

Interface

UseAudioPlayerOptions

Options for useAudioPlayer.

Interface

UseChannelEffectOptions

Options for useChannelEffect. Extends the projection options (bufferSize, replay) with the per-event callback, an optional error sink, a reactive target scope, and a reactive enabled gate.

Interface

UseStreamReturn

Vue binding return type for useStream.

Reactive primitives follow Vue conventions:

  • Data projections are Readonly<ShallowRef<T>> / ComputedRef<T> so templates auto-unwrap via msg.value in
Interface

UseSubmissionQueueReturn

Reactive handle on the server-side submission queue.

Populated when submit() is invoked with multitaskStrategy: "enqueue" while another run is in flight. The returned refs are shared per call — s

Interface

UseVideoPlayerOptions

Options for useVideoPlayer.

Interface

VideoMedia

Shared surface across every media handle returned by MediaAssembler.

The handle is live while its parent message is active:

  • partialBytes is a snapshot of all bytes received so far.
  • stream i
Interface

VideoPlayerHandle

Controls + live state returned by useVideoPlayer. Mirrors AudioPlayerHandle on the shared subset so callers only ever learn one shape.

Type

AgentServerOptions

Type

AnyHeadlessToolImplementation

Type

AnyMediaHandle

Type

AnyStream

Erased handle useful as a parameter type for helpers and wrapper components that pass a stream through to selector composables without reading values directly. Mirrors the React AnyStream alias.

Type

CustomAdapterOptions

Type

DefaultToolCall

Default tool call type when no specific tool definitions are provided.

Type

InferStateType

Unwrap the state shape from a compiled graph, a create-agent brand, or a plain type. Used by useStream<T>() to resolve T = typeof agent into the state the values/messages projections observe.

Type

InferSubagentStates

Infer the subagent → state map from a DeepAgent brand. Non-brands collapse to DefaultSubagentStates.

Type

InferToolCalls

Infer the discriminated union of AssembledToolCall handles from an agent brand, an array of LangChain tools, or fall back to the untyped default handle.

Pass typeof agent or typeof tools and narr

Type

MediaAssemblyErrorKind

Kinds of failure that can terminate a media handle prematurely.

  • "message-error" — the upstream message emitted an error event before completion.
  • "stream-closed" — the transport stream clo
Type

MediaBlockType

Block types this assembler knows how to reassemble into media handles.

Type

MessageMetadataMap

Read-only map exposed via MessageMetadataTracker.store.

Type

OnToolCallback

Type

PlayerStatus

Lifecycle state of an audio or video player returned by useAudioPlayer and useVideoPlayer.

Type

SelectorTarget

What a selector composable can be targeted at. Callers can pass:

  • undefined / null — root namespace (served by the always-on root store — no extra subscription);
  • a SubagentDiscoverySnapsho
Type

SubmissionQueueSnapshot

Read-only snapshot of the queue. The queue store hands this out directly; consumers must not mutate the array.

Type

ToolCallFromTool

Infer the streaming AssembledToolCall handle for a single LangChain tool.

Parallel to ToolCallFromTool for message-level tool calls — use this when a component receives one entry from `stream.toolCal

Type

ToolCallsFromTools

Infer a union of tool call types from an array of tools. Works with tools created via tool() from @langchain/core/tools.

Type

ToolCallState

The lifecycle state of a tool call.

  • pending: Tool call received, awaiting result
  • completed: Tool execution finished successfully
  • error: Tool execution failed (result.status === "error")
Type

ToolCallStatus

High-level outcome of a single tool call.

Type

ToolCallWithResult

Represents a tool call paired with its result. Useful for rendering tool invocations and their outputs together.

Type

UseStreamOptions

Type

UseStreamResult

Convenience alias for the fully-resolved stream handle type.

Type

VueReactiveOptions

Wraps specific option keys to accept MaybeRefOrGetter for Vue reactivity. Allows options like assistantId, apiUrl, threadId, etc. to be passed as plain values, Vue refs, or getter functions.

Type

WidenUpdateMessages

Widen an update type so its messages field also accepts @langchain/core BaseMessage class instances (single or array). Framework bindings apply this to submit() so callers can write `stream.subm