Skill: ai-sdk-ui
Scope
- Applies to:
@ai-sdk/reactuseChatandDefaultChatTransportfromai - Does NOT cover: Backend generation (see ai-sdk-core)
Assumptions
- SDK major is
ai^7;@ai-sdk/reactis a separate package major. Folder followsai - Never write
useChatfrom memory. Grepnode_modules/@ai-sdk/react/docs/andnode_modules/ai/docs/, else https://ai-sdk.dev/docs/ai-sdk-ui/chatbot - Chat HTTP may be Fastify; pass
transportwhen the URL is not/api/chat
Principles
useChatfrom@ai-sdk/react;DefaultChatTransportfromai- Local input state;
sendMessage({ text });statusnotisLoading; rendermessage.parts - Server: see ai-sdk-core. Handlers use
createUIMessageStreamResponse+toUIMessageStream({ stream: result.stream }). Leave deprecatedtoUIMessageStreamResponse()only when the task is unrelated to streaming or the SDK
Constraints
MUST
DefaultChatTransport({ api })when the endpoint is not/api/chat- Disable send while
status !== 'ready'
AVOID
import { useChat } from 'ai/react'toDataStreamResponse/pipeDataStreamToResponse- Pre-v5
handleInputChange/handleSubmit/useAssistant
Interactions
- Uses ai-sdk-core
- Complements fastify, next
Templates
- use-chat-basic.tsx
- nextjs-api-route.ts
- nextjs-chat-app-router.tsx