LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
React SDK
Vue SDK
Svelte SDK
Angular SDK
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
WebChannelsPregelPrebuiltRemote
React SDK
Vue SDK
Svelte SDK
Angular SDK
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/vueuseProjection
Function●Since v1.0

useProjection

Copy
useProjection<
  T
>(
  registry: MaybeRefOrGetter<ChannelRegistry | null | undefined>,
  specFactory: () =>
View source on GitHub
ProjectionSpec
<
T
>
,
key
:
MaybeRefOrGetter
<
string
>
,
initialValue
:
T
)
:
Readonly
<
ShallowRef
<
T
>
>

Parameters

NameTypeDescription
registry*MaybeRefOrGetter<ChannelRegistry | null | undefined>
specFactory*() => ProjectionSpec<T>
key*MaybeRefOrGetter<string>
initialValue*T

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 setup() (or whenever registry / key change) the composable acquires a ref-counted projection from the registry and subscribes to its store. Vue re-renders automatically whenever the store's snapshot changes.
  • On onScopeDispose (or when registry / key change) the previous acquisition is released. If this was the last consumer of that spec, the registry closes the underlying server subscription.
  • When registry is null/undefined the composable stays at initialValue. This is the happy path for root-served projections (useMessages, useToolCalls, useValues) which delegate to the always-on root store instead of acquiring a new registry projection.

registry and key accept MaybeRefOrGetter so selector composables can pass a reactive target (e.g. a computed subagent snapshot) and have the projection rebind automatically.

Returns a Readonly<ShallowRef<T>> so templates auto-unwrap and scripts can computed(() => proj.value). The underlying ref is shallowRef — consumers that mutate the snapshot get undefined behaviour; stream projections should always be treated as immutable snapshots.