← Back to list

ai-sdk-v6-ui
by blockmatic
FullStack Web3 & AI Project Starter
⭐ 4🍴 0📅 Jan 22, 2026
SKILL.md
name: AI SDK v6 UI description: | Build React chat interfaces with Vercel AI SDK v5/v6. Agent integration, tool approval, auto-submit.
Use when: implementing AI SDK v5/v6 chat UIs or troubleshooting "useChat failed to parse stream", "useChat no response", or "stale body values" errors.
Skill: ai-sdk-ui
Scope
- Applies to: React chat interfaces with Vercel AI SDK v5/v6, streaming UI patterns, tool approval workflows, agent integration
- Does NOT cover: Backend AI implementation (see ai-sdk-core), Generative UI/RSC
Assumptions
- AI SDK v5.0.99+ (stable) or v6.0.0-beta.108+ (beta)
- React 18+ (React 19 supported)
- Next.js 14+ (13.4+ works)
@ai-sdk/reactpackage
Principles
- Use
useChatfor chat interfaces with streaming - Use
useCompletionfor text completion (non-chat) - Use
useObjectfor structured data generation - Use
useAssistantfor OpenAI-compatible assistant APIs - Use streaming for better UX (show tokens as they arrive)
- Handle tool approval workflows with
addToolApprovalResponse(v6) - Use controlled mode for dynamic body values (avoid stale values)
- Use
toDataStreamResponse()in App Router,pipeDataStreamToResponse()in Pages Router
Constraints
MUST
- Use streaming responses (
toDataStreamResponse()orpipeDataStreamToResponse()) - Use controlled mode when body values change (
sendMessagewithdatainstead ofbodyoption) - Handle loading states (
isLoading) and errors (error)
SHOULD
- Use
stopfunction to allow users to cancel generation - Auto-scroll to latest message during streaming
- Show loading indicators during generation
- Use
InferAgentUIMessage(v6) for type-safe agent integration
AVOID
- Using
bodyoption with dynamic values (causes stale values) - Non-streaming responses (poor UX)
- Infinite loops in
useEffect(only depend onmessages, not callbacks) - Mixing v5 and v6 APIs without migration
Interactions
- Uses ai-sdk-core for backend implementation
- Works with nextjs App Router and Pages Router
- Uses Zod for schema validation (see typescript)
Patterns
Basic Chat
import { useChat } from '@ai-sdk/react'
export default function Chat() {
const { messages, input, handleInputChange, handleSubmit, isLoading } = useChat({
api: '/api/chat',
})
return (
<form onSubmit={handleSubmit}>
<input value={input} onChange={handleInputChange} />
<button disabled={isLoading}>Send</button>
</form>
)
}
Tool Approval (v6)
import { useChat } from '@ai-sdk/react'
const { messages, addToolApprovalResponse } = useChat({
api: '/api/chat',
})
// Handle approval
addToolApprovalResponse({
toolCallId: 'id',
approved: true,
})
See Templates and Next.js Integration for detailed examples.
References
- Next.js Integration - App Router and Pages Router patterns
- Streaming Patterns - UI streaming best practices
- Top UI Errors - Common error solutions
Resources
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon