LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Overview
  • Getting started
  • injectStream
  • Selectors
  • Interrupts & headless tools
  • Subagents & subgraphs
  • Fork & edit from a checkpoint
  • Submission queue
  • Multimodal media
  • Transports
  • Dependency injection
  • 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
WebChannelsPregelPrebuiltRemote
OverviewGetting startedinjectStreamSelectorsInterrupts & headless toolsSubagents & subgraphsFork & edit from a checkpointSubmission queueMultimodal mediaTransportsDependency injectionType 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/angularGetting started

Getting started

@langchain/angular ships injectStream together with a small family of companion selector hooks. The root hook gives you always-on access to thread state, messages, tool calls, and interrupts; the selector hooks open ref-counted subscriptions for the things that aren't needed on every view (per-subagent messages, media streams, submission queue, message metadata, raw channels).

Learn more: For end-to-end tutorials and UI patterns, see the LangChain frontend documentation.

Installation

npm install @langchain/angular @langchain/core

Peer dependencies: @angular/core (^19 || ^20) and @langchain/core.

Your first chat

Mount injectStream once per thread. Point it at a running agent server and render messages:

import { Component, inject } from "@angular/core";
import { injectStream } from "@langchain/angular";

@Component({
  /* ... */
})
export class Chat {
  readonly stream = injectStream({
    assistantId: "agent",
    apiUrl: "http://localhost:2024",
  });

  readonly messages = this.stream.messages;
  readonly isLoading = this.stream.isLoading;

  send() {
    void this.stream.submit({ messages: [{ type: "human", content: "Hello!" }] });
  }
}

Use the graph name from your langgraph.json as assistantId.

Mental model

@langchain/angular splits the surface into two layers:

  1. Root hook (injectStream). Owns the thread lifecycle, the transport, and a handful of always-on projections: values, messages, toolCalls, interrupts, error, isLoading, and the subagent / subgraph discovery maps. Mount it once per thread.
  2. Companion inject* selectors. Each opens a ref-counted subscription when the first component mounts it and releases it when the last consumer unmounts. Use them for anything scoped to a namespace, a subagent / subgraph, a specific message, an extension channel, or a media stream.
import { injectStream, injectMessages, injectSubmissionQueue } from "@langchain/angular";

function Chat() {
  const stream = injectStream({ assistantId: "agent", apiUrl: "/api" });

  // Root: free read, no new subscription.
  const messages = injectMessages(stream); // same as stream.messages

  // Scoped: opens a subscription on mount.
  const queue = injectSubmissionQueue(stream);
}

The key idea: views that don't render a subagent's messages never pay for that subagent's wire traffic. Subscriptions follow the injector tree.

Runnable examples

The streaming cookbook collects end-to-end, runnable apps built on these hooks. Clone it and run any example from the typescript/ workspace:

Example Shows
ui-angular A chat app with browser reconnect / replay — refresh mid-stream and reattach.
multimodal Streaming text, images, audio, and video from scoped graph nodes.
a2ui Generative UI rendered from a custom:a2ui extension channel.
react-custom-transport Wiring injectStream to your own backend transport.
streaming Terminal scripts for messages, subgraphs, subagents, HITL, and more.

Where to go next

injectStream

Every option, callback, and return value on the root injector.

Selectors

Scoped state, submission queue, message metadata, and raw events.

Interrupts

Pause for human approval, edits, or headless tool resolution.

Fork & edit

Edit a turn or retry from an earlier checkpoint.

Subagents

Visualize subagents and nested subgraphs with lazy subscriptions.

Multimodal

Stream audio, images, video, and files from scoped graph nodes.

Transports

Connect to Agent Server (SSE/WebSocket) or your own backend adapter.

Type safety

Full type inference from typeof agent and shared stream types.

Functions

Function

injectStream

Angular entry point for the v2-native stream runtime.