Skip to content
AI Monorepos Free online conference · June 23 Join us!

TanStack AI template

A streaming, type-safe AI chat with tool calling on TanStack Start.

Terminal window
npx create-nx-workspace@latest my-workspace --template nrwl/tanstack-ai-template
TanStack AI template preview

An AI chat app: a TanStack Start front end wired to TanStack AI for streaming chat, isomorphic tool calling, and agents - provider-agnostic and defaulting to Claude. Tools are defined once and run on the server with full type safety, and it lives in an Nx monorepo with a shared tool library, caching, and affected builds.

Highlights

Streaming and type-safe

TanStack AI streams responses end to end with full TypeScript inference - typed messages, tools, and structured outputs.

Define a tool once

Isomorphic tools run on the server but are callable by the model and your components, with one definition and automatic validation.

Provider-agnostic

Ships with Claude by default. Swap to OpenAI, Gemini, or OpenRouter by changing a single adapter line.

Built on Nx

A shared tool library, caching, and affected builds keep the AI app fast to iterate on and ready to scale.

Quickstart

  • Add your Anthropic API key:
    Terminal window
    echo "ANTHROPIC_API_KEY=sk-ant-..." >> .env
  • Start the chat app:
    Terminal window
    npx nx run @tanstack-ai-template/web:dev
  • Build every project:
    Terminal window
    npx nx run-many -t build
  • Visualize your monorepo's graph in the browser:
    Terminal window
    npx nx graph

What's inside

  • apps/web - TanStack Start app with a streaming chat UI
  • packages/ai - shared TanStack AI tool definitions and types
  • A server route that streams chat over Server-Sent Events

Speed up CI with Nx Cloud

Connect this monorepo to Nx Cloud to share one remote cache across your team and CI, and distribute tasks across machines as it grows.

  • Remote caching shared across your team and CI
  • Distributed task execution with Nx Agents
  • Automated e2e test splitting
  • CI that detects failures and proposes fixes

Learn more