published fresh until

Next.js and AI SDK: how do I build a chatbot with streaming replies?

Summary When building a Next.js chat UI with streaming, stop controls, and refresh-safe conversations, compare the three UI kits and fixes for delayed or cut-off streams; chat history stored in a database has no tested answer.

Not for answers from my PDFs, see case-rag-over-pdfs-parsing-chunking-embeddings-no-invented-answers-eval-set; asking a database in plain words, see case-ask-database-questions-in-plain-english-text-to-sql-postgres-duckdb; abuse by prompts, see case-llm-feature-with-tools-prompt-injection-proof-test-scan

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The case

You want a chat page in your product: messages stream in, a stop button works, the conversation survives a refresh and the layout behaves. Success looks like: text appearing token by token in production, long answers finishing, and a chat UI that is not hand-built. Stack: Next.js, Vercel AI SDK, React.

This is a map, not new advice: every row points to an existing WhatWorks thread. Nobody here ran this whole build; the Status column says what each linked thread rests on. "Tried" would need a linked trial report, and none of the linked threads has one yet.

Parts, in the order people do them

PartWhat to useStatusLink
Chat UI kitAI Elements components for the AI SDK; shadcn/ui for new projectsDocumented: vendor or primary source, not tried (no linked trial)How do I build a chat UI for an AI app with Vercel's AI Elements?
Chat UI with shadcn partsMessage scroller rule and componentsDocumented: vendor or primary source, not tried (no linked trial)How do I get my agent to build a chat UI with shadcn components?
ChatGPT-style threadReady-made thread componentDocumented: vendor or primary source, not tried (no linked trial)How do I add a ChatGPT-style chat to my React app with assistant-ui?
Stream arrives all at onceBuffering after deployDocumented: vendor or primary source, not tried (no linked trial)My AI chat answer shows up all at once after deploy: why?
Stream stops partwayProxy timeouts on long answersDocumented: vendor or primary source, not tried (no linked trial)Why does my AI chat stream stop partway on long answers?
Reply lost on refreshResumable streams and stop buttonDocumented: vendor or primary source, not tried (no linked trial)My AI chat loses the reply when the user refreshes: how to resume?
Chat history saved in a databaseNo tested answer yetNo tested answer yetnone (see open request)

Where it breaks

Open questions

  • Parts marked "No tested answer yet" are gaps in WhatWorks; ask for them with the request tool so an editor can look: storing and listing past conversations per user.

Sources

Each linked WhatWorks thread cites its own primary sources; this page adds none of its own. Status labels were read from the linked thread pages on 19 October 2026.

As of October 2026. answers from your own PDFs, see case-rag-over-pdfs-parsing-chunking-embeddings-no-invented-answers-eval-set; prompt injection, see case-llm-feature-with-tools-prompt-injection-proof-test-scan.

Started from a post by @WhatWorks editors, packaged by the editor.

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Next.js and AI SDK: how do I build a chatbot with streaming replies?
Summary: When building a Next.js chat UI with streaming, stop controls, and refresh-safe conversations, compare the three UI kits and fixes for delayed or cut-off streams; chat history stored in a database has no tested answer.
Copy for agent
get the whatworks thread case-ai-chatbot-app-streaming-replies-chat-ui-resume-nextjs-ai-sdk and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread case-ai-chatbot-app-streaming-replies-chat-ui-resume-nextjs-ai-sdk
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks