Skip to main content
Build rich, interactive frontends for agents created with createAgent. These patterns cover everything from basic message rendering to advanced workflows like human-in-the-loop approval and time travel debugging.

Architecture

Every pattern follows the same architecture: a createAgent backend streams state to a frontend via the useStream hook. On the backend, createAgent produces a compiled LangGraph graph that exposes a streaming API. On the frontend, the useStream hook connects to that API and provides reactive state — messages, tool calls, interrupts, history, and more — that you render with any framework.
from langchain import create_agent
from langgraph.checkpoint.memory import MemorySaver

agent = create_agent(
    model="openai:gpt-5.4",
    tools=[get_weather, search_web],
    checkpointer=MemorySaver(),
)
useStream is available for React, Vue, Svelte, and Angular:
import { useStream } from "@langchain/react";   // React
import { useStream } from "@langchain/vue";      // Vue
import { useStream } from "@langchain/svelte";   // Svelte
import { useStream } from "@langchain/angular";  // Angular

Patterns

Render messages and output

Markdown messages

Parse and render streamed markdown with proper formatting and code highlighting.

Structured output

Render typed agent responses as custom UI components instead of plain text.

Reasoning tokens

Display model thinking processes in collapsible blocks.

Generative UI

Render AI-generated user interfaces from natural language prompts using json-render.

Display agent actions

Tool calling

Show tool calls as rich, type-safe UI cards with loading and error states.

Human-in-the-loop

Pause the agent for human review with approve, reject, and edit workflows.

Manage conversations

Branching chat

Edit messages, regenerate responses, and navigate conversation branches.

Message queues

Queue multiple messages while the agent processes them sequentially.

Advanced streaming

Join & rejoin streams

Disconnect from and reconnect to running agent streams without losing progress.

Time travel

Inspect, navigate, and resume from any checkpoint in the conversation history.

Integrations

useStream is UI-agnostic. Use it with any UI component library:

AI Elements

Composable, shadcn/ui-based components — Conversation, Message, Tool, Reasoning, PromptInput, and more. Components ship as source files you own.

assistant-ui

Headless React framework with thread management, message branching, and a ready-to-use <Thread /> component. Connects via useExternalStoreRuntime.