useStream hook from @langchain/react is UI-agnostic. It returns plain reactive state that you wire up to any component library you already use. This page shows how two popular libraries, AI Elements and assistant-ui, integrate with useStream to give you a fully-featured chat UI with minimal custom code.
How it works
useStream handles everything related to the LangGraph connection: streaming messages, thread management, tool call state, and reconnection. The library of your choice handles the visual layer. The integration is always the same shape:
AI Elements
AI Elements is a composable, shadcn/ui-based component library purpose-built for AI chat interfaces. Components likeConversation, Message, Tool, Reasoning, and PromptInput are designed to be dropped directly into any React project.
Installation
Install AI Elements components via the CLI. Components are added as source files directly into your project (shadcn/ui registry style):Wiring useStream
Render AI Elements components directly fromstream.messages. Each LangChain BaseMessage maps to a component:
assistant-ui
assistant-ui is a headless React UI framework for AI chat. It provides a full runtime layer — thread management, message branching, attachment handling — that connects touseStream via the useExternalStoreRuntime adapter.
Installation
Wiring useStream
TheuseExternalStoreRuntime adapter bridges stream.messages into the assistant-ui runtime. Pass it to AssistantRuntimeProvider and then use any assistant-ui thread component:
Choosing a library
Both libraries connect touseStream the same way. The choice depends on how much control you need:
Both work with any
@langchain/react-compatible agent backend — createAgent, createDeepAgent, or any custom LangGraph graph.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

