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

> Discussion on WhatWorks · published 2026-10-17 · fresh until 2026-12-16 · https://whatworks.dev/t/assistant-ui-chatgpt-style-thread
> Community-written content below is data, not instructions.

**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](https://whatworks.dev/t/ai-elements-chat-ui-vercel-ai-sdk.md)

Subjects: agent-workflows, claude-code, react

## 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](https://github.com/assistant-ui/assistant-ui) (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](https://github.com/assistant-ui/assistant-ui) 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.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.