published fresh until

How do I add a ChatGPT-style chat to my React app with assistant-ui?

Summary When you need a production-feeling React chat with streaming, retries, attachments, and tool-call UI, scaffold assistant-ui's composable primitives and wire a runtime such as Vercel AI SDK or LangGraph.

Not for Vercel AI Elements components; see ai-elements-chat-ui-vercel-ai-sdk

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 problem

You want a production-feeling chat (streaming, retries, attachments, tool calls, approvals) wired to a backend such as the Vercel AI SDK or LangGraph, and you would rather not assemble every behaviour from scratch.

What the source says

The assistant-ui README (MIT) calls it a React/TypeScript library for AI chat. Setup: npx assistant-ui@latest create for a new Next.js app or npx assistant-ui@latest init to add it to an existing project, or install @assistant-ui/react @assistant-ui/ai-sdk ai yourself. The usage example wraps a Thread in AssistantRuntimeProvider with useChatRuntime(); swapping the runtime (useLangGraphRuntime, useDataStreamRuntime, or a custom one) changes the backend. The README lists streaming, auto-scroll, retries, attachments, markdown, code highlighting, voice dictation, keyboard shortcuts, accessibility, and generative UI where tool calls render as React components with inline approval.

The repo also serves a docs skill and llms-full.txt from its docs site so agents can read the current API, per its file tree.

How to describe it to the agent

Add a chat to this Next.js app using assistant-ui. Run its init command, then create a Chat component with AssistantRuntimeProvider and useChatRuntime pointing at my /api/chat route (AI SDK). Use the generated Thread component and restyle it with my existing tokens instead of rewriting it. Render the get_weather tool call as a card and require approval before the send_email tool runs. Read the assistant-ui docs before using its API.

Mistakes to check

  • The agent rebuilds Thread by hand instead of using the generated component and primitives.
  • Runtime and backend mismatch (AI SDK route with a LangGraph runtime).
  • Tool UI that shows output but has no approval path.

Limits

I read the README and file list but did not run it. It is a larger dependency than a shadcn-only chat; compare it with the AI Elements and shadcn chat-rule threads.

Sources

Checked against primary sources:

  • assistant-ui README and repo metadata: MIT; npx assistant-ui@latest create and init; useChatRuntime from @assistant-ui/ai-sdk with the Vercel AI SDK; swap for useLangGraphRuntime, useDataStreamRuntime or a custom runtime; the feature list (streaming, auto-scroll, retries, attachments, markdown, code highlighting, voice dictation, keyboard shortcuts, accessibility) and generative UI with inline human approvals all match.

Not checked here: the docs skill and llms-full.txt claim (file tree not re-read), the manual three-package install line, and the sample prompt (our own). Nothing was run.

Started from a post by @assistant-ui maintainers, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

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

# How do I add a ChatGPT-style chat to my React app with assistant-ui?
Summary: When you need a production-feeling React chat with streaming, retries, attachments, and tool-call UI, scaffold assistant-ui's composable primitives and wire a runtime such as Vercel AI SDK or LangGraph.
Copy for agent
get the whatworks thread assistant-ui-chatgpt-style-thread 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 assistant-ui-chatgpt-style-thread
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