assistant-ui
294
总安装量
295
周安装量
#901
全站排名
安装命令
npx skills add https://github.com/assistant-ui/skills --skill assistant-ui
Agent 安装分布
claude-code
202
codex
191
opencode
182
gemini-cli
174
github-copilot
156
cursor
134
Skill 文档
assistant-ui
Always consult assistant-ui.com/llms.txt for latest API.
React library for building AI chat interfaces with composable primitives.
References
- ./references/architecture.md — Core architecture and layered system
- ./references/packages.md — Package overview and selection guide
When to Use
| Use Case | Best For |
|---|---|
| Chat UI from scratch | Full control over UX |
| Existing AI backend | Connects to any streaming backend |
| Custom message types | Tools, images, files, custom parts |
| Multi-thread apps | Built-in thread list management |
| Production apps | Cloud persistence, auth, analytics |
Architecture
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â UI Components (Primitives) â
â ThreadPrimitive, MessagePrimitive, ComposerPrimitive â
âââââââââââââââââââââââââââ¬ââââââââââââââââââââââââââââââââ
â
âââââââââââââââââââââââââââ¼ââââââââââââââââââââââââââââââââ
â Context Hooks â
â useAssistantApi, useAssistantState, useAssistantEvent â
âââââââââââââââââââââââââââ¬ââââââââââââââââââââââââââââââââ
â
âââââââââââââââââââââââââââ¼ââââââââââââââââââââââââââââââââ
â Runtime Layer â
â AssistantRuntime â ThreadRuntime â MessageRuntime â
âââââââââââââââââââââââââââ¬ââââââââââââââââââââââââââââââââ
â
âââââââââââââââââââââââââââ¼ââââââââââââââââââââââââââââââââ
â Adapters/Backend â
â AI SDK · LangGraph · Custom · Cloud Persistence â
âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
Pick a Runtime
Using AI SDK?
ââ Yes â useChatRuntime (recommended)
ââ No
ââ External state (Redux/Zustand)? â useExternalStoreRuntime
ââ LangGraph agent? â useLangGraphRuntime
ââ AG-UI protocol? â useAgUiRuntime
ââ A2A protocol? â useA2ARuntime
ââ Custom API â useLocalRuntime
Core Packages
| Package | Purpose |
|---|---|
@assistant-ui/react |
UI primitives & hooks |
@assistant-ui/react-ai-sdk |
Vercel AI SDK v6 adapter |
@assistant-ui/react-langgraph |
LangGraph adapter |
@assistant-ui/react-markdown |
Markdown rendering |
@assistant-ui/styles |
Pre-built CSS |
assistant-stream |
Streaming protocol |
assistant-cloud |
Cloud persistence |
Quick Start
import { AssistantRuntimeProvider, Thread } from "@assistant-ui/react";
import { useChatRuntime, AssistantChatTransport } from "@assistant-ui/react-ai-sdk";
function App() {
const runtime = useChatRuntime({
transport: new AssistantChatTransport({ api: "/api/chat" }),
});
return (
<AssistantRuntimeProvider runtime={runtime}>
<Thread />
</AssistantRuntimeProvider>
);
}
State Access
import { useAssistantApi, useAssistantState } from "@assistant-ui/react";
const api = useAssistantApi();
api.thread().append({ role: "user", content: [{ type: "text", text: "Hi" }] });
api.thread().cancelRun();
const messages = useAssistantState(s => s.thread.messages);
const isRunning = useAssistantState(s => s.thread.isRunning);
Related Skills
/setup– Installation and configuration/primitives– UI component customization/runtime– State management deep dive/tools– Tool registration and UI/streaming– Streaming protocols/cloud– Persistence and auth/thread-list– Multi-thread management/update– Version updates and migrations