1. Message Parts Structure (Breaking Change)
In v6, message content is now accessed via .parts array instead of .content:
CODEBLOCK0
Part Types:
- text - Text content with .text property
INLINECODE4 - Tool calls with .toolName, .args, INLINECODE7
INLINECODE8 - File attachments with .mimeType, INLINECODE10
INLINECODE11 - Model reasoning (when available)
INLINECODE12 - Source citations
3. Agent Integration
Type-safe messaging with agents using InferAgentUIMessage<typeof agent>:
CODEBLOCK1
4. Tool Approval Workflows (Human-in-the-Loop)
Request user confirmation before executing tools:
CODEBLOCK2
5. Auto-Submit Capability
Automatically continue conversation after handling approvals:
CODEBLOCK3
6. Structured Output in Chat
Generate structured data alongside tool calling (previously only available in useObject):
CODEBLOCK4
useChat Hook - v4 → v5 Breaking Changes
CRITICAL: useChat no longer manages input state in v5!
v4 (OLD - DON'T USE):
CODEBLOCK5
v5 (NEW - CORRECT):
CODEBLOCK6
Summary of v5 Changes:
1. Input management removed: input, handleInputChange, handleSubmit no longer exist
append() → sendMessage(): New method for sending messages
onResponse removed: Use onFinish instead
initialMessages → controlled mode: Use messages prop for full control
maxSteps removed: Handle on server-side only
See references/use-chat-migration.md for complete migration guide.
useAssistant Hook (Deprecated)
⚠️ Deprecation Notice: useAssistant is deprecated as of AI SDK v5. OpenAI Assistants API v2
will sunset on August 26, 2026. For new projects, use useChat with custom backend logic instead.
See the openai-assistants skill for migration guidance.
Interact with OpenAI-compatible assistant APIs with automatic UI state management.
Import:
CODEBLOCK7
Basic Usage:
CODEBLOCK8
Use Cases:
- Building OpenAI Assistant-powered UIs
Managing assistant threads and runs
Streaming assistant responses with UI state management
File search and code interpreter integrations
See official docs for complete API reference: https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-assistant
Top UI Errors & Solutions
See references/top-ui-errors.md for complete documentation. Quick reference:
1. useChat Failed to Parse Stream
Error: INLINECODE29
Cause: API route not returning proper stream format.
Solution:
CODEBLOCK9
2. useChat No Response
Cause: API route not streaming correctly.
Solution:
CODEBLOCK10
3. Streaming Not Working When Deployed
Cause: Deployment platform buffering responses.
Solution: Vercel auto-detects streaming. Other platforms may need configuration.
4. Stale Body Values with useChat
Cause: body option captured at first render only.
Solution:
CODEBLOCK11
5. React Maximum Update Depth
Cause: Infinite loop in useEffect.
Solution:
CODEBLOCK12
See references/top-ui-errors.md for 13 more common errors (18 total documented).
Streaming Best Practices
Performance
Always use streaming for better UX:
CODEBLOCK13
UX Patterns
Show loading states:
CODEBLOCK14
Provide stop button:
CODEBLOCK15
Auto-scroll to latest message:
CODEBLOCK16
Disable input while loading:
CODEBLOCK17
See references/streaming-patterns.md for comprehensive best practices.
React Strict Mode Considerations
React Strict Mode intentionally double-invokes effects to catch bugs. When using useChat or useCompletion in effects (auto-resume, initial messages), guard against double execution to prevent duplicate API calls and token waste.
Problem:
CODEBLOCK18
Solution:
CODEBLOCK19
Why It Happens: React Strict Mode double-invokes effects to surface side effects. The SDK doesn't guard against concurrent requests, so both invocations create separate streams that fight for state updates.
- Initial release of ai-sdk-ui for building React chat interfaces with Vercel AI SDK v6.
- Supports new message parts structure, type-safe agent integration, tool approval workflows, and auto-submit.
- Provides 18 documented UI error solutions, addressing issues with React Strict Mode, concurrent requests, and stale closures.
- Includes migration guidance from v5 to v6, highlighting breaking changes in hooks and state management.
- Offers best practices and troubleshooting for common chat UI errors.