
Ai Sdk Ui
- 196 repo stars
- Updated July 25, 2026
- secondsky/claude-skills
Build React/Next.js AI chat UIs with Vercel AI SDK v5 hooks (useChat, useCompletion, useObject) and debug streaming issues.
About
Skill covering Vercel AI SDK v5 React hooks (useChat, useCompletion, useObject) for building AI chat interfaces. A developer uses it when constructing React or Next.js AI front-ends and troubleshooting parse-stream, no-response, or streaming errors.
- useChat / useCompletion / useObject
- Streaming chat UIs
- Vercel AI SDK v5
- React/Next.js debugging
Ai Sdk Ui by the numbers
- Data as of Jul 28, 2026 (Skillselion catalog sync)
/plugin marketplace add secondsky/claude-skills/plugin install ai-sdk-ui@claude-skillsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| repo stars | ★ 196 |
|---|---|
| Last updated | July 25, 2026 |
| Repository | secondsky/claude-skills ↗ |
What it does
Build React/Next.js AI chat UIs with Vercel AI SDK v5 hooks (useChat, useCompletion, useObject) and debug streaming issues.
README.md
AI SDK UI - Frontend React Hooks
Version: AI SDK v5.0.76+ Status: Production-Ready ✅ Framework: React 18+, Next.js 14+ Last Updated: 2025-10-22
What This Skill Does
Provides complete implementation patterns for Vercel AI SDK v5 frontend React hooks:
- useChat - Chat interfaces with streaming
- useCompletion - Text completions
- useObject - Streaming structured data
Focus: React UI layer for AI-powered applications.
Auto-Trigger Keywords
This skill should be automatically discovered when working with any of the following:
Primary Keywords (Highest Priority)
ai sdk uiuseChat hookuseCompletion hookuseObject hookreact ai chatai chat interfacechat ui reactai sdk reactvercel ai uiai react hooksstreaming ai uireact streaming chatnextjs ai chatnextjs ainext.js chatai chat componentreact ai components
Secondary Keywords (Medium Priority)
nextjs app router ainextjs pages router aichat message statemessage persistence aiai file attachmentsfile upload ai chatstreaming chat reactreal-time ai chattool calling uiai tools reactai completion reacttext completion uistructured data streaminguseObject streamingreact chat appreact ai application
Error-Based Keywords (Trigger on Errors)
useChat failed to parse streamparse stream erroruseChat no responsechat hook no responseunclosed streams aistream not closingstreaming not working deployedvercel streaming issuestreaming not working proxiedproxy bufferingstrange stream output0: characters streamstale body values useChatbody not updatingcustom headers not working useChatreact maximum update depthinfinite loop useChatrepeated assistant messagesduplicate messagesonFinish not calledstream abortedv5 migration useChatuseChat breaking changesinput handleInputChange removedsendMessage v5
Framework Integration Keywords
nextjs ai integrationnext.js ai sdkvite react airemix ai chatvercel ai deployment
Provider Keywords
openai react chatanthropic react chatclaude chat uigpt chat interface
Quick Start
bun add ai @ai-sdk/openai # preferred
# or: npm install ai @ai-sdk/openai
5-minute chat interface:
// app/chat/page.tsx
'use client';
import { useChat } from 'ai/react';
import { useState } from 'react';
export default function Chat() {
const { messages, sendMessage, isLoading } = useChat({ api: '/api/chat' });
const [input, setInput] = useState('');
return (
<div>
{messages.map(m => (
<div key={m.id}>{m.role}: {m.content}</div>
))}
<form onSubmit={(e) => {
e.preventDefault();
sendMessage({ content: input });
setInput('');
}}>
<input value={input} onChange={(e) => setInput(e.target.value)} />
</form>
</div>
);
}
// app/api/chat/route.ts
import { streamText } from 'ai';
import { openai } from '@ai-sdk/openai';
export async function POST(req: Request) {
const { messages } = await req.json();
const result = streamText({ model: openai('gpt-4-turbo'), messages });
return result.toDataStreamResponse();
}
What's Included
Templates (11)
- use-chat-basic.tsx - Basic chat with v5 input management
- use-chat-tools.tsx - Chat with tool calling UI
- use-chat-attachments.tsx - File attachments support
- use-completion-basic.tsx - Text completion streaming
- use-object-streaming.tsx - Structured data streaming
- nextjs-chat-app-router.tsx - Next.js App Router complete example
- nextjs-chat-pages-router.tsx - Next.js Pages Router complete example
- nextjs-api-route.ts - API route for both routers
- message-persistence.tsx - localStorage persistence
- custom-message-renderer.tsx - Markdown & code highlighting
- package.json - Dependencies template
References (5)
- use-chat-migration.md - Complete v4→v5 migration guide
- streaming-patterns.md - UI streaming best practices
- top-ui-errors.md - 12 common UI errors with solutions
- nextjs-integration.md - Next.js setup patterns
- links-to-official-docs.md - Official docs organization
Scripts (1)
- check-versions.sh - Verify package versions
Critical v5 Changes
BREAKING: useChat no longer manages input state!
v4 (OLD):
const { input, handleInputChange, handleSubmit } = useChat();
<input value={input} onChange={handleInputChange} />
v5 (NEW):
const { sendMessage } = useChat();
const [input, setInput] = useState('');
<input value={input} onChange={(e) => setInput(e.target.value)} />
Other changes:
append()→sendMessage()onResponseremoved → useonFinishinitialMessages→ controlled mode withmessagespropmaxStepsremoved (handle server-side)
See references/use-chat-migration.md for complete migration guide.
Token Savings
Without skill: ~15,500 tokens (research, trial-and-error, debugging) With skill: ~7,000 tokens (templates, references, examples)
Savings: ~55% (8,500 tokens)
Errors Prevented
This skill documents and prevents 12 common UI errors:
- useChat failed to parse stream
- useChat no response
- Unclosed streams
- Streaming not working when deployed
- Streaming not working when proxied
- Strange stream output (0:... characters)
- Stale body values
- Custom headers not working
- React maximum update depth
- Repeated assistant messages
- onFinish not called when aborted
- Type errors with message parts
When to Use This Skill
Use ai-sdk-ui when:
- Building React chat interfaces
- Implementing AI completions in UI
- Streaming AI responses to frontend
- Building Next.js AI applications
- Handling chat message state
- Displaying tool calls in UI
- Managing file attachments with AI
- Migrating from v4 to v5
- Encountering useChat/useCompletion errors
Don't use when:
- Need backend AI (use ai-sdk-core instead)
- Building non-React frontends (check official docs)
- Need Generative UI / RSC (advanced topic)
Related Skills
- ai-sdk-core - Backend text generation, structured output, tools, agents
- Compose both for full-stack AI applications
Package Versions
Required:
ai: ^5.0.76@ai-sdk/openai: ^2.0.53react: ^18.2.0zod: ^3.23.8
Next.js:
next: ^14.0.0react: ^18.2.0react-dom: ^18.2.0
Official Documentation
Core UI Hooks:
- AI SDK UI Overview: https://ai-sdk.dev/docs/ai-sdk-ui/overview
- useChat: https://ai-sdk.dev/docs/ai-sdk-ui/chatbot
- useCompletion: https://ai-sdk.dev/docs/ai-sdk-ui/completion
- useObject: https://ai-sdk.dev/docs/ai-sdk-ui/object-generation
Next.js:
- App Router: https://ai-sdk.dev/docs/getting-started/nextjs-app-router
- Pages Router: https://ai-sdk.dev/docs/getting-started/nextjs-pages-router
Migration:
Production Validation
Tested In: WordPress Auditor (https://wordpress-auditor.webfonts.workers.dev)
Verified:
- ✅ All 11 templates work copy-paste
- ✅ v5 breaking changes documented
- ✅ 12 common errors prevented
- ✅ Package versions current (2025-10-22)
- ✅ Next.js App Router & Pages Router examples
- ✅ Token savings: 55%
License: MIT