JavaScript/TypeScript agent orchestration
LangGraph.js is a graph-based agent framework for JavaScript and TypeScript. Built by the LangChain team, it follows the same API as Python LangGraph but uses idiomatic JS/TS patterns: Annotation instead of TypedDict, Zod schemas instead of type hints, and async functions throughout.
You define your workflow as a graph where nodes are async functions and edges control execution flow. Each node reads from a shared state object and returns partial updates. Conditional edges let you route between nodes based on the current state.
LangGraph.js runs anywhere JavaScript runs: Node.js, Deno, Cloudflare Workers, Vercel Edge Functions, and browsers. It works as a standalone library without LangChain, though the two integrate well together.
Core concepts
LangGraph.js is built around a few primitives. They combine in different ways depending on what you are building.
StateGraph
The core class for building workflows. Pass it an Annotation schema, add nodes and edges, then compile it into a runnable graph.
Learn moreAnnotation
Define your state schema with Annotation.Root(). Each field can have a reducer function that controls how updates are merged.
Learn moreNodes
Async functions that do the actual work. Each node takes the current state, performs some action, and returns partial updates.
Learn moreEdges
Connections between nodes that define execution flow. Normal edges always go to the same next node. Conditional edges route based on state.
Learn moreTools
Functions agents can call during execution. Defined with tool() from @langchain/core/tools using Zod schemas. LangGraph.js provides ToolNode for easy integration.
Learn moreCheckpointers
Persistence backends that save graph state between runs. MemorySaver for development, with SQLite, Postgres, MongoDB, and Redis for production.
Learn moreGo deeper
Each guide covers one concept with code examples and practical patterns.
LangGraph.js Agents
Build ReAct agents with tool calling and reasoning loops.
LangGraph.js State
Annotation, nodes, edges, conditional routing, and reducers.
LangGraph.js Tools
Tool integration with ToolNode and toolsCondition.
LangGraph.js Memory
MemorySaver, checkpointers, and persistent state.
Deploy LangGraph.js
Step-by-step guide to production deployment.
How LangGraph.js works
A typical LangGraph.js project follows three steps: define your state with Annotation, write async node functions, and wire them together into a graph.
1. Define state
State is defined with Annotation.Root(). Use MessagesAnnotation for message lists with built-in append behavior.
2. Write nodes
Each node is an async function that takes the current state and returns partial updates. Here, the chatbot node calls an LLM and returns the response.
3. Build and compile
Create a StateGraph, add your nodes, connect them with edges, and call compile(). The compiled graph is ready to invoke with app.invoke().
import { StateGraph, Annotation, START, END, MessagesAnnotation } from "@langchain/langgraph"
import { ChatAnthropic } from "@langchain/anthropic"
// Define the state
const StateAnnotation = Annotation.Root({
...MessagesAnnotation.spec,
})
// Create an LLM
const model = new ChatAnthropic({ model: "claude-sonnet-4-20250514" })
// Define nodes
async function chatbot(state: typeof StateAnnotation.State) {
const response = await model.invoke(state.messages)
return { messages: [response] }
}
// Build the graph
const graph = new StateGraph(StateAnnotation)
.addNode("chatbot", chatbot)
.addEdge(START, "chatbot")
.addEdge("chatbot", END)
// Compile and run
const app = graph.compile()
const result = await app.invoke({
messages: [{ role: "user", content: "What is LangGraph.js?" }],
})Common use cases
LangGraph.js is general-purpose. If your workflow needs explicit control flow or human oversight, it is probably a good fit.
Conversational Agents
Chatbots that maintain state across turns, call tools when needed, and remember earlier messages.
Research Agents
Agents that pull information from multiple sources, cross-check it, and retry when results are incomplete.
Document Processing
Pipelines that extract data from documents, validate it, and route to different processing paths based on content type.
Data Analysis
Agents that query databases, run calculations, and produce reports. Add human approval steps before final output.
Code Generation
Agents that write code, run tests, check results, and iterate. Self-correcting loops are a natural fit for graphs.
E-commerce Workflows
Order processing, inventory checks, and customer service bots. Tools give agents access to your systems; human escalation handles edge cases.
How LangGraph.js compares to other frameworks
LangGraph.js sits at a different level than frameworks like the Vercel AI SDK or Mastra. Those provide higher-level abstractions for common patterns. LangGraph.js gives you lower-level building blocks: nodes, edges, state, and conditional routing.
The trade-off is more control for more setup. You can implement any execution pattern: sequential pipelines, parallel fan-out, self-correcting loops, human approval gates, and multi-agent supervisor architectures. Nothing is hidden behind an abstraction you cannot modify.
Compared to the Python version, LangGraph.js shares the same core API. If your team works in TypeScript, you get the same graph primitives without switching languages. Crewship supports both, so you can choose the right runtime for each project.
FAQ
Common questions about LangGraph.js
Deploy LangGraph.js with Crewship
Built your graph? Crewship deploys it to production with a single command. You get a production API, real-time streaming, auto-scaling, and Slack integration.