Installation
Detailed setup guide for streamResource() in your Angular application.
Requirements
streamResource() uses Angular Signals and the modern injection context API. Angular 20 or later is required.
Required for the build toolchain and package installation.
A running LangGraph agent accessible via HTTP. Can be local (langgraph dev) or deployed (LangGraph Cloud).
Install the package
npm install @cacheplane/stream-resourceThis installs the library and its peer dependencies including @langchain/langgraph-sdk.
Configure the provider
Add provideStreamResource() to your application configuration. This sets global defaults for all streamResource instances.
// app.config.ts
import { ApplicationConfig } from '@angular/core';
import { provideStreamResource } from '@cacheplane/stream-resource';
import { environment } from '../environments/environment';
export const appConfig: ApplicationConfig = {
providers: [
provideStreamResource({
apiUrl: environment.langgraphUrl,
}),
],
};Any option passed to streamResource() directly overrides the global provider config. You can set a default apiUrl globally and override it for specific agents.
Environment setup
For local development, configure your environment and run a LangGraph server:
// src/environments/environment.ts
export const environment = {
langgraphUrl: 'http://localhost:2024',
};# Start LangGraph dev server
langgraph dev
# Your agent will be available at http://localhost:2024Verify installation
Create a minimal component to verify the setup works. streamResource() must be called in an injection context (a component field initializer or inside inject()).
// In a component field initializer (injection context)
const test = streamResource({ assistantId: 'chat_agent' });
console.log(test.status()); // 'idle' — setup is correctTroubleshooting
Version mismatch -- If you see errors about missing APIs or unknown decorators, confirm your Angular version is 20 or later. Run ng version to check. Earlier versions do not support the injection context APIs that streamResource() relies on.
CORS errors -- If the browser console shows Access-Control-Allow-Origin errors, your LangGraph server is not configured for cross-origin requests. The LangGraph dev server allows all origins by default. For production, make sure your deployment's CORS policy includes your Angular app's domain.
Connection refused -- If you see ERR_CONNECTION_REFUSED, verify your LangGraph server is running and that the apiUrl matches the correct host and port. Run langgraph dev and confirm the server starts at the expected address (default http://localhost:2024).
"NullInjectorError: No provider for StreamResourceConfig" -- You forgot to add provideStreamResource() to your appConfig providers array. See the Configure the provider section above.