lukasa1993/tanstack-skills-extracted/tanstack-ai-core-chat-experience
Claude Code and agent skill by lukasa1993/tanstack-skills-extracted
- community
Checking that the SKILL.md file is still in the repository.
End-to-end chat implementation: server endpoint with chat() and toServerSentEventsResponse(), client-side useChat hook with fetchServerSentEvents(), message rendering with UIMessage parts, multimodal content, thinking/reasoning display. Covers streaming states, connection adapters, and message format conversions. NOT Vercel AI SDK — uses chat() not streamText().
Install
npx vskill@latest install lukasa1993/tanstack-skills-extracted/tanstack-ai-core-chat-experienceSKILL.md
Chat Experience
This skill builds on ai-core. Read it first for critical rules.
Setup — Minimal Chat App
Server: API Route (TanStack Start)
Client: React Component
Vue/Solid/Svelte/Preact have identical patterns with different hook imports (e.g., import { useChat } from '@tanstack/ai-solid').
Core Patterns
1. Streaming Chat with SSE
Server returns a streaming SSE Response; client parses it automatically.
Server:
To make the SSE response resumable (reconnect after a drop/refresh without re-running the provider), pass a delivery-durability adapter: toServerSentEventsResponse(stream, { durability: { adapter: memoryStream(request) } }) (memoryStream from @tanstack/ai is process-local, for dev/tests) or durableStream(request, { server }) from @tanstack/ai-durable-stream (Durable Streams protocol, production). Each SSE event gets an opaque adapter-owned id:; fetchServerSentEvents auto-reconnects with Last-Event-ID and exposes joinRun(runId) to replay a run from the start. See docs/resumable-streams/overview.md.
Client:
The forwardedProps field goes to the server as AG-UI forwardedProps. The server reads params.forwardedProps.provider, params.forwardedProps.model, and so on. (body on useChat was removed in 1.0.)
The status field tracks the chat lifecycle: 'ready' | 'submitted' | 'streaming' | 'error'.
2. Rendering Thinking/Reasoning Content
Models with extended thinking (Claude, Gemini) emit ThinkingPart in the message parts array.
Server-side, turn thinking on with the reasoning option on chat():
3. Sending Multimodal Content (Images)
Use sendMessage with a MultimodalContent object instead of a plain string.
Render image parts in received messages:
For media reused across turns, upload once via a provider Files adapter (openaiFiles(), anthropicFiles(), geminiFiles(), grokFiles(), falFiles()) and send a { type: 'file' } source built with fileSourceFromHandle(handle) instead of re-sending base64 each request. The source is { type: 'file', value, provider }: an opaque handle and the adapter that issued it. A different provider (or one without Files API support at all) rejects it with a clear error before any request is sent. The source crosses the chat wire, so the browser can put it straight into the sendMessage content. Import fileSourceFromHandle from the browser-safe @tanstack/ai/client entry. See ../tanstack-ai-core-adapter-configuration/SKILL.md §7 and docs/advanced/files-api.md.
4. Sending Audio Messages (Browser Recording)
Use useAudioRecorder from @tanstack/ai-react (or createAudioRecorder in Svelte) to capture audio in the browser. The resolved AudioRecording includes a ready-to-use part that slots directly into sendMessage.
recording.part is { type: 'audio', source: { type: 'data', value: base64, mimeType } }. Returns the recorder's native format (audio/webm or audio/mp4) with no transcoding.
5. HTTP Stream Format (Alternative to SSE)
Use toHttpResponse + fetchHttpStream for newline-delimited JSON instead of SSE.
Server:
Client:
The only difference is swapping toServerSentEventsResponse / fetchServerSentEvents for toHttpResponse / fetchHttpStream. Everything else stays identical.
This includes resumability: pass the same durability adapter to toHttpResponse(stream, { durability: { adapter: memoryStream(request) } }) and each NDJSON line becomes an { id, chunk } envelope. fetchHttpStream auto-reconnects with Last-Event-ID, de-dupes the replayed prefix, and exposes joinRun(runId) — the same guarantees as resumable SSE. The XHR adapters (xhrServerSentEvents / xhrHttpStream) are resumable too.
6. MCP Tool Discovery via chat({ mcp })
Pass mcp to let chat() own discovery and lifecycle for one or more MCP clients. Useful when you want minimal boilerplate and don't need to reuse the clients across calls.
createMCPClient tries spec 2026-07-28 first. If the server does not support that spec, the client uses the 2025 initialize handshake.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/tanstack-ai-core-chat-experience/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/lukasa1993/tanstack-skills-extracted/tanstack-ai-core-chat-experience)