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.
import { createAgent } from "langchain";
import { MemorySaver } from "@langchain/langgraph";

const agent = createAgent({
  model: "openai:gpt-4.1",
  tools: [getWeather, searchWeb],
  checkpointer: new 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

Display agent actions

Manage conversations

Advanced streaming