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/angularDependency injection

Dependency injection

provideStream and provideStreamDefaults wire LangGraph streaming through Angular's dependency injection. Child components read a shared stream with injectStream.

Application defaults

Set apiUrl (and optional client / apiKey) once in app.config.ts:

import { ApplicationConfig } from "@angular/core";
import { provideStreamDefaults } from "@langchain/angular";

export const appConfig: ApplicationConfig = {
  providers: [
    provideStreamDefaults({
      apiUrl: "http://localhost:2024",
    }),
  ],
};

Any injectStream call in the app inherits those defaults unless overridden per call.

Shared stream at component level

Add provideStream to a parent component's providers array so descendants share one stream instance:

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

@Component({
  providers: [provideStream({ assistantId: "agent" })],
  template: `
    <app-message-list />
    <app-message-input />
  `,
})
export class ChatContainer {}

@Component({
  template: `
    @for (msg of stream.messages(); track msg.id) {
      <div>{{ msg.content }}</div>
    }
  `,
})
export class MessageListComponent {
  readonly stream = injectStream();
}

Companion selectors (injectMessages, injectToolCalls, etc.) take the stream handle from injectStream():

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

@Component({
  /* ... */
})
export class MessageListComponent {
  private readonly stream = injectStream();
  readonly messages = injectMessages(this.stream);
}

Type inference

Pass the agent brand to injectStream to flow state / tool-call / subagent inference through:

import type { agent } from "./agent";
import { injectStream } from "@langchain/angular";

readonly stream = injectStream<typeof agent>();

See Type safety.

Nested layouts (multi-agent)

Provide separate provideStream({ assistantId: "…" }) entries on different parent components — each injector subtree gets its own stream handle.

Custom adapters

provideStream accepts the same discriminated option bag as injectStream, including a custom AgentServerAdapter:

import { HttpAgentServerAdapter, provideStream } from "@langchain/angular";

const transport = new HttpAgentServerAdapter({
  apiUrl: "/api/chat",
  threadId: "thread-123",
});

@Component({
  providers: [provideStream({ transport })],
  /* ... */
})
export class ChatContainer {}

See Transports.

API reference

Functions

Function

provideStream

Creates a provider for a shared useStream instance at the component level.

Function

provideStreamDefaults

Provides default LangGraph configuration at the application level.

Function

injectStream

Angular entry point for the v2-native stream runtime.

Interfaces

Interface

StreamDefaults

Configuration defaults for useStream and injectStream calls.

Constants

Variable

STREAM_DEFAULTS

Injection token for stream default configuration.