Immutable solution version
useChat client in App Router: DefaultChatTransport, sendMessage, manual input state
Complete solution
How the client side of useChat looks in AI SDK 7: transport object, sendMessage with a text message, and input state you manage yourself.
useChat in v7 takes a transport object, not api/headers options, and it no longer manages your input field. Old tutorials will mislead you on both.
'use client';
import { useChat } from '@ai-sdk/react'; import { DefaultChatTransport } from 'ai'; import { useState } from 'react';
export default function Page() { const { messages, sendMessage, status, error, stop } = useChat({ transport: new DefaultChatTransport({ api: '/api/chat' }), }); const [input, setInput] = useState('');
// Render structure (JSX): // fragment // messages.map(message => // [div keyed by message id] // role label: message.role === 'user' ? 'User: ' : 'AI: ' // message.parts.map((part, i) => // part.type === 'text' ? [span keyed by i] holding part.text : null)) // [form onSubmit]: e.preventDefault(); sendMessage({ text: input }); setInput('') // [input]: value={input}, onChange={e => setInput(e.target.value)} sendMessage({ text: input }); setInput(''); }}> [input value={input} onChange={e =] setInput(e.target.value)} /> [/form] [/] ); }
Checklist:
- Wrap options in new DefaultChatTransport({ api: '/api/chat' }). Passing api/headers/credentials directly to useChat was removed in v5.
- Manage input with your own useState. The old input, handleInputChange, handleSubmit return values are gone.
- Send with sendMessage({ text: input }), not handleSubmit. Request extras go in the second arg: sendMessage({ text }, { body: { custom: 'value' } }).
- Render message.parts, not message.content. Text lives in parts with type 'text'. Tool calls live in tool parts on the same array.
- status tells you 'submitted' | 'streaming' | 'ready' | 'error'. Use it for spinners and to disable the form while streaming.
- The old data and allowEmptySubmit request options were removed in v5. Move custom data into body.
Evidence
Verified against the live AI SDK docs 2026-09-26. The AI SDK UI chatbot guide shows the useChat example with DefaultChatTransport, sendMessage({ text }), manual useState input, and message.parts rendering. The v5 migration guide documents the transport architecture change, removed managed input state, sendMessage replacing handleSubmit, and the removed data/allowEmptySubmit options.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_ffLY_6xDf3Brsi32IB0kxg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">useChat client in App Router: DefaultChatTransport, sendMessage, manual input state <span>— Vectle</span></a>