npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tanstack/ai-angular

v0.0.1

Published

Angular signals integration for TanStack AI streaming chat, structured outputs, and media generation.

Readme

TanStack AI — Angular

Angular signal-based bindings for TanStack AI — streaming chat, tool-calling agents, and media generation built on Angular's native reactivity model.

Read the docs ->

Install

pnpm add @tanstack/ai-angular @tanstack/ai
npm install @tanstack/ai-angular @tanstack/ai

Minimal Usage

Important: All inject* functions use Angular's dependency injection system and must be called within an Angular injection context — a component or directive class field initializer, the constructor, or inside runInInjectionContext. Calling them outside an injection context will throw a runtime error.

The example below shows a standalone component that streams chat messages from a server endpoint via SSE:

import { Component } from '@angular/core'
import { CommonModule } from '@angular/common'
import { injectChat } from '@tanstack/ai-angular'
import { fetchServerSentEvents } from '@tanstack/ai-client'

@Component({
  selector: 'app-chat',
  standalone: true,
  imports: [CommonModule],
  template: `
    <ul>
      @for (message of chat.messages(); track message.id) {
        <li>{{ message.role }}: {{ message.content }}</li>
      }
    </ul>
    <input #input placeholder="Type a message..." />
    <button (click)="chat.sendMessage(input.value); input.value = ''">
      Send
    </button>
    @if (chat.isLoading()) {
      <p>Thinking...</p>
    }
  `,
})
export class ChatComponent {
  // injectChat is called in a field initializer — this is a valid injection context.
  chat = injectChat({
    connection: fetchServerSentEvents('/api/chat'),
  })
}

All state is exposed as Angular Signals. Read them by calling them as functions:

| Signal | Type | Description | | ------------------------- | -------------------- | ------------------------------------------- | | chat.messages() | UIMessage[] | Current message list | | chat.isLoading() | boolean | Whether a response is streaming | | chat.error() | Error \| undefined | Last error, if any | | chat.status() | ChatClientState | 'ready', 'streaming', 'error', ... | | chat.isSubscribed() | boolean | Whether a live (SSE push) session is active | | chat.connectionStatus() | ConnectionStatus | Transport connection status |

Available methods on the return value: sendMessage, append, reload, stop, clear, setMessages, addToolResult, addToolApprovalResponse.

Server endpoint

The client pairs with any endpoint that returns a TanStack AI SSE stream:

import { chat, toServerSentEventsResponse } from '@tanstack/ai'
import { openaiText } from '@tanstack/ai-openai'

export async function POST(request: Request) {
  const body = await request.json()

  const stream = chat({
    adapter: openaiText('gpt-5.5'),
    messages: body.messages,
  })

  return toServerSentEventsResponse(stream)
}

Available Functions

| Function | Description | | ---------------------- | ---------------------------------------------------------------- | | injectChat | Streaming chat with messages, tool calls, and structured outputs | | injectGeneration | Generic generation client (streaming or one-shot) | | injectGenerateImage | Image generation | | injectGenerateAudio | Audio generation | | injectGenerateVideo | Video generation | | injectGenerateSpeech | Text-to-speech | | injectSummarize | Summarization | | injectTranscription | Audio transcription |

All generation functions return signals (result, isLoading, error, status) and methods (generate, stop, reset).

Injection Context

Angular's DI system requires that inject() is called during component construction. Every inject* function in this package calls inject() internally. Valid call sites:

// Field initializer (recommended)
export class MyComponent {
  chat = injectChat({ connection: fetchServerSentEvents('/api/chat') })
}

// Constructor
export class MyComponent {
  chat: ReturnType<typeof injectChat>
  constructor() {
    this.chat = injectChat({ connection: fetchServerSentEvents('/api/chat') })
  }
}

// Inside runInInjectionContext
const chat = runInInjectionContext(injector, () =>
  injectChat({ connection: fetchServerSentEvents('/api/chat') }),
)

Get Involved