Updated October 23, 2026: rebuilt the post around Mastra vs LangChain.js/LangGraph.js, with October 2026 versions, funding, GitHub and npm numbers, hosted pricing and licensing, and Mastra code samples rewritten for the 1.x API.
If you are a TypeScript team starting a new agent product, pick Mastra. It ships agents, workflows, memory, evals, tracing and a local Studio in one Apache 2.0 framework, and its defaults get you to a working agent faster than LangChain.js does. Pick LangChain.js with LangGraph.js when you need explicit, inspectable control over every state transition, when your agent logic has to mirror a Python LangGraph codebase, or when your company already runs on LangSmith. The two are closer in adoption than most comparisons suggest: Mastra has 29,000 GitHub stars against 18,300 for LangChain.js, while LangChain’s packages still lead on npm, with 1.73 million weekly downloads for langchain and 2.07 million for @langchain/langgraph against 1.33 million for @mastra/core (week of October 12 to 18, 2026).
“LangChain” in TypeScript means three products, and the comparison only works once you separate them. langchain 1.x is the high-level agent API (createAgent plus middleware), rebuilt in October 2025 to run on the LangGraph runtime. LangGraph.js is the low-level runtime for durable, stateful agents. LangSmith is the commercial platform for tracing, evals and deployment. Mastra covers the first two layers in a single framework and sells its own platform for the third.
Mastra vs LangChain at a Glance (October 2026)
| Mastra | LangChain.js + LangGraph.js | |
|---|---|---|
| Current version | @mastra/core 1.79 (Oct 21, 2026) | langchain 1.5, @langchain/langgraph 1.5 |
| Stable since | 1.0 on January 20, 2026 | 1.0 in October 2025, “no breaking changes until 2.0” |
| Shape | One framework: agents, workflows, memory, RAG, evals, MCP, server | Layered: createAgent on the LangGraph runtime, integrations as separate packages |
| Orchestration | Chained workflows: .then(), .branch(), .parallel(), suspend/resume | Explicit StateGraph: nodes, edges, conditional edges, interrupt() |
| Memory | Message history by default; working memory, semantic recall, Observational Memory | Checkpointers per thread, Stores for long-term memory, you choose the trimming strategy |
| Evals | Built-in scorers with live sampling, datasets and experiments in Studio | LangSmith datasets and experiments, Vitest/Jest integration |
| Observability | Built-in tracing, exporters for LangSmith, Langfuse, Braintrust, Datadog, Arize, OpenTelemetry | LangSmith |
| Local dev UI | Mastra Studio (mastra dev) | LangSmith Studio |
| Deployment | Any Node host; deployers for Vercel, Netlify, Cloudflare; hosted Mastra Server | Any Node host as a library; managed runtime via LangSmith Deployment |
| License | Apache 2.0, except ee/ directories (commercial license) | MIT |
| Hosted platform pricing | Starter $0, Teams $250/month, Enterprise custom | Developer $0, Plus $39/seat/month, Enterprise custom |
| Company funding | $35M total ($22M Series A, April 2026) | $125M Series B at $1.25B valuation (October 2025) |
| GitHub stars | 29.0k | 18.3k (LangChain.js) + 3.4k (LangGraph.js) |
| npm weekly downloads | 1.33M (@mastra/core) | 1.73M (langchain), 2.07M (@langchain/langgraph) |
| Best for | TypeScript-only teams shipping agent products | Complex control flow, Python parity, LangSmith shops |
Sources for every row are linked in the sections below.
Architecture: One Framework vs a Layered Stack
Mastra registers everything on one Mastra instance: agents, workflows, storage, memory, scorers and observability. Models are plain provider/model strings that go through Mastra’s model router, which covers 8,181 models from 218 providers. Under the hood Mastra plugs into Vercel AI SDK model providers (1.0 added AI SDK v6 support), not LangChain.
LangChain splits the same job across packages. createAgent from langchain runs the model-and-tools loop, and you customize it with middleware: humanInTheLoopMiddleware for approvals, piiMiddleware for redaction, modelRetryMiddleware and toolRetryMiddleware for flaky providers. When that loop is not enough, you drop down to LangGraph.js and draw the graph yourself. Above both sits Deep Agents, LangChain’s library for building controllable agents on LangGraph (219,000 weekly npm downloads).
Here is the same tool-calling agent in both. Mastra, following the current agent docs:
import { Agent } from '@mastra/core/agent';
import { createTool } from '@mastra/core/tools';
import { z } from 'zod';
const weatherTool = createTool({
id: 'get-weather',
description: 'Get current weather for a city',
inputSchema: z.object({ city: z.string() }),
execute: async ({ city }) => {
const res = await fetch(`https://api.weather.gov/...`);
return res.json();
},
});
export const weatherAgent = new Agent({
id: 'weather-agent',
name: 'Weather Agent',
instructions: 'You help users check weather conditions.',
model: 'openai/gpt-5.5',
tools: { weatherTool },
});
LangChain.js, following the createAgent docs:
import { createAgent, tool } from 'langchain';
import { MemorySaver } from '@langchain/langgraph';
import * as z from 'zod';
const getWeather = tool(
async ({ city }) => {
const res = await fetch(`https://api.weather.gov/...`);
return JSON.stringify(await res.json());
},
{
name: 'get_weather',
description: 'Get current weather for a city',
schema: z.object({ city: z.string() }),
},
);
const agent = createAgent({
model: 'openai:gpt-5.5',
tools: [getWeather],
systemPrompt: 'You help users check weather conditions.',
checkpointer: new MemorySaver(),
});
For a single agent, the APIs are now almost the same length. The differences are telling, though. Mastra uses provider/model, LangChain uses provider:model. LangChain makes you pass a checkpointer before a conversation survives between calls, while Mastra stores threads through the storage adapter you configure once on the Mastra instance. That pattern repeats everywhere: LangChain hands you primitives and asks you to choose, Mastra picks a default and lets you override it.
Workflows vs Graphs
This is where the two frameworks actually differ. Mastra workflows are chains of typed steps, built with createWorkflow and createStep from @mastra/core/workflows:
import { createWorkflow } from '@mastra/core/workflows';
import { z } from 'zod';
// enrichFromCRM, assignDedicatedRep, addToSelfServe and
// sendWelcomeEmail are steps defined with createStep()
export const onboardingWorkflow = createWorkflow({
id: 'customer-onboarding',
inputSchema: z.object({ email: z.string(), seats: z.number() }),
outputSchema: z.object({ status: z.string() }),
})
.then(enrichFromCRM)
.branch([
[async ({ inputData }) => inputData.seats >= 50, assignDedicatedRep],
[async ({ inputData }) => inputData.seats < 50, addToSelfServe],
])
.then(sendWelcomeEmail)
.commit();
One gotcha from the control-flow docs: .branch() is not if/else. Every condition is evaluated, and every branch whose condition is true runs, so keep your conditions mutually exclusive. For human-in-the-loop, a step calls suspend(), Mastra writes a snapshot to your storage provider, and run.resume() continues from that step later. Snapshots persist across deployments and restarts, so a workflow can wait hours for an approval without losing state. Replit, whose Agent 3 builds Mastra agents for its users, reports that workflow success rose from 80% to 96%, which it credits to Mastra’s durable execution with Inngest. That is Mastra’s own case study, so read it as a vendor claim.
The LangGraph.js version of the same flow uses the Graph API:
import { StateGraph, START, END, MemorySaver } from '@langchain/langgraph';
const graph = new StateGraph(State)
.addNode('enrich', enrichFromCRM)
.addNode('dedicatedRep', assignDedicatedRep)
.addNode('selfServe', addToSelfServe)
.addNode('welcome', sendWelcomeEmail)
.addEdge(START, 'enrich')
.addConditionalEdges('enrich', (s) => (s.seats >= 50 ? 'dedicatedRep' : 'selfServe'))
.addEdge('dedicatedRep', 'welcome')
.addEdge('selfServe', 'welcome')
.addEdge('welcome', END)
.compile({ checkpointer: new MemorySaver() });
More lines, but every transition is an explicit edge you can read, test and replay. Edges can point backwards, so loops are first-class. With a checkpointer, every step is persisted per thread_id, and an interrupt() call pauses inside a node until you resume with Command({ resume }). Durable state, built-in persistence and first-class human-in-the-loop were the headline features of LangGraph 1.0.
My take: if your process is a pipeline with a few branches and approval gates, Mastra’s chain is easier to read in code review. If the control flow is the product (multi-agent handoffs, retry loops, state you need to inspect mid-run), LangGraph’s explicit graph pays for its verbosity. For the design side of approval gates, see our guide to human-in-the-loop AI agents.
Memory and RAG
Most production agents need context beyond the current conversation. A support agent needs your account history; a research agent needs your internal docs. Both frameworks handle this, with opposite philosophies.
Mastra’s memory has four layers. Message history is on by default. Working memory keeps structured user facts such as names and preferences. Semantic recall retrieves older messages by meaning. Observational Memory, the option Mastra recommends, runs two background agents: an Observer that compresses message history into notes once it passes 30,000 tokens (typically 5x to 40x compression), and a Reflector that condenses those notes once they pass 40,000 tokens. The default model: 'auto' picks a cheap model from your main provider, or Gemini 2.5 Flash if a Google key is set. The trade-off is that those background calls cost tokens you will not notice unless tracing is on. Mastra also sells a hosted Memory Gateway that works with other frameworks, and ships RAG building blocks (chunking, embedding, vector store queries) in @mastra/rag.
LangChain.js gives you primitives. Short-term memory is a checkpointer plus a thread_id: MemorySaver for development, PostgresSaver for production. Long conversations are your problem to manage: trim, delete, or add summarizationMiddleware with your own token trigger. Long-term memory lives in a LangGraph Store (InMemoryStore for development, PostgresStore for production) as namespaced JSON documents that tools read and write through runtime.store, with vector search if you configure embeddings. On RAG, LangChain’s JS integration catalog of document loaders and vector stores is still deeper than Mastra’s.
Mastra does more for you on day one. LangChain makes the context window your decision, which is exactly what you want once token costs matter.
Evals and Observability
Mastra ships evals in the framework. Scorers from @mastra/evals (model-graded, rule-based and statistical) attach to agents or individual workflow steps with a sampling rate, run asynchronously without blocking responses, and write results to a mastra_scorers table. In Mastra Studio, the local UI that mastra dev serves on localhost:4111, you can turn a scored trace into a dataset item and run experiments against agents or workflows. Studio also lets you chat with agents, run tools in isolation and step through workflows visually. It is the most useful part of Mastra’s developer experience, and since April 2026 you can also deploy it for your team.
Tracing creates a span for every agent run, workflow step, tool call and model call, with token counts and cost estimates. Exporters exist for LangSmith, Langfuse, Braintrust, Datadog, Arize and any OpenTelemetry backend. So picking Mastra does not stop your team from using LangSmith.
LangSmith is the strongest part of LangChain’s offer. You can write evals as ordinary Vitest or Jest suites via langsmith/vitest: each test case becomes a dataset example and each run becomes an experiment. The October 2026 release round added semantic AI Search over traces, Engine v2 with red teaming, and Fine-Tuning that turns production trajectories into training data for Baseten or Fireworks. LangSmith also traces non-LangChain frameworks such as Vercel AI SDK and CrewAI. For a wider view of eval platforms, see our AI agent evaluation tools comparison.
Deployment, Licensing and Hosted Pricing
Both frameworks run in any Node.js process. The differences are in the tooling and the paid platforms.
Mastra. mastra build produces a Hono server for a VM, container or PaaS, with built-in deployers for Vercel, Netlify and Cloudflare and guides for AWS Lambda, Kubernetes, Amazon Bedrock AgentCore, Inngest and Temporal. Since 1.0, server adapters also mount Mastra inside an existing Express, Hono, Fastify or Koa app. The hosted Mastra platform (Studio, Server, Memory Gateway) has a free Starter tier with 100K observability events and 24 CPU hours included, then $10 per 100K events and $0.35 per CPU hour; a persistent 24/7 server costs $100 per project. Teams costs $250 per month with 1M events, 250 CPU hours, six-month retention, SSO and SOC 2 documentation. Enterprise is custom, including a self-hosted license sold as a flat annual fee.
The license needs a careful read. Everything is Apache 2.0 except directories named ee/, such as @mastra/core/auth/ee, @mastra/core/agent-builder/ee and @mastra/editor/ee. That code is source-available under the Mastra Enterprise License: free for development and testing, paid for production. Agents, workflows and memory are unaffected, but check your imports before you build on auth or the agent builder.
LangChain. LangChain.js and LangGraph.js are MIT. The managed runtime is LangSmith Deployment, which LangChain renamed from LangGraph Platform in October 2025. On the pricing page, Developer is free with 5,000 base traces per month and one seat. Plus costs $39 per seat per month with 10,000 base traces and one free small serverless deployment. Further deployments are metered in LangSmith Units at $1 each (for example, 0.0675 units per vCPU-hour of runtime compute). Self-hosted and hybrid LangSmith are Enterprise-only.
Neither framework forces its platform on you. The lock-in lives in the platforms: Mastra’s ee/ features on one side, LangSmith Deployment and its proprietary tooling on the other.
Ecosystem, Adoption and Maturity
On raw numbers, Mastra has caught up with LangChain in TypeScript. It has more GitHub stars than the LangChain.js repo (29.0k vs 18.3k), and @mastra/core downloads now sit within shouting distance of langchain. Treat @langchain/core’s 3.55 million weekly downloads with care: many other packages pull it in. The LangChain ecosystem’s center of gravity is still Python, with 148,000 stars on langchain and 43,800 on langgraph.
Money tells a similar story. Mastra, built by the team behind Gatsby and led by CEO Sam Bhagwat, raised a $13 million seed and then a $22 million Series A led by Spark Capital on April 9, 2026, for $35 million in total. LangChain raised $125 million at a $1.25 billion valuation in October 2025, led by IVP.
Production users: Mastra names Brex, Indeed (a nationally advertised career counselor agent), Marsh McLennan (enterprise search used by more than 100,000 people daily), Replit, and platform teams at MongoDB, Workday and Salesforce in its Series A post. LangChain lists Klarna, Uber and J.P. Morgan among LangGraph users.
Maturity is where LangChain now has the edge, which is a reversal of its old reputation for API churn. LangChain promised “no breaking changes until 2.0” at 1.0 and has stayed on the 1.x line for a year. Mastra moves much faster: @mastra/core went from 1.0.0 to 1.79.0 in nine months, and minor releases still carry breaking changes. Version 1.77.0 (October 14, 2026), for example, made @mastra/server workflow routes return 404 for internal workflows, so durable agents must now be called through agent routes. Pin your versions and read the release notes.
Both support MCP, through @mastra/mcp and @langchain/mcp-adapters, so the MCP tool ecosystem is open to either choice.
When to Pick Mastra and When to Pick LangChain
Choose Mastra when your team writes TypeScript only and is building a standalone agent product. You want memory, evals, tracing and a dev UI working on day one, not after a week of wiring. You deploy to Vercel, Netlify or Cloudflare, or embed agents in an existing Express, Hono, Fastify or Koa app. You can live with a fast release cadence.
Choose LangChain.js and LangGraph.js when the agent’s control flow is complex: loops, multi-agent handoffs, state you need to inspect and replay. Your company has Python LangGraph code, and you want the same concepts on both sides. You already pay for LangSmith, or procurement wants self-hosted observability and an enterprise SLA from a larger vendor. You value an API stability promise over new features every week.
The practical heuristic: if the control flow is the hard part, use LangGraph.js. If shipping the product around the agent is the hard part, use Mastra. And if your team splits the difference, Mastra’s LangSmith exporter lets you build in Mastra and still debug in LangSmith.
Other TypeScript Agent Options
Vercel AI SDK is the integration layer most TypeScript AI code already uses, at 18.4 million weekly npm downloads. AI SDK 7, released June 25, 2026, added durable agents through WorkflowAgent, tool approvals, OpenTelemetry telemetry and timeouts, which narrows the gap to full frameworks. If you are adding AI features to an existing Next.js app, start here. Mastra itself builds on AI SDK model providers, so moving up later is not a rewrite of your model layer.
OpenAI Agents SDK for TypeScript covers agents, tools, guardrails, sessions and tracing in the @openai/agents packages. It is the lightweight choice if you are committed to OpenAI models.
Why TypeScript for Agents at All
Python still has the larger ecosystem for ML and data science. But the argument for TypeScript agents is not about replacing Python for model training. It is about where agents actually run.
A customer support agent handling 50,000 conversations a day needs WebSocket connections, streaming responses and session management. A sales agent that qualifies leads needs to call CRM APIs, send emails and update databases in real time. A coding agent embedded in VS Code runs in a Node.js process.
These are JavaScript-native environments. Running a Python subprocess, managing a virtual environment and serializing data across the language boundary adds friction that TypeScript agents avoid. That is why both Mastra and LangChain treat TypeScript as a first-class target rather than a port.
Frequently Asked Questions
Is Mastra better than LangChain for TypeScript developers?
For most new TypeScript-only agent products, yes. Mastra bundles agents, workflows, memory, evals, tracing and a local Studio in one Apache 2.0 framework, and its defaults get you to a working agent faster. LangChain.js with LangGraph.js is the better choice when you need explicit graph-level control over agent state, share designs with a Python LangGraph team, or already use LangSmith. LangChain’s 1.x line also promises no breaking changes until 2.0, while Mastra still ships breaking changes in minor releases.
What is the difference between Mastra and LangGraph.js?
LangGraph.js is a low-level runtime: you define state, nodes and edges, and add a checkpointer for durability and an interrupt for human approval. Mastra is a full framework whose workflows are chained steps (.then, .branch, .parallel) with suspend and resume, plus built-in memory, evals and a dev UI. LangGraph gives you more explicit control; Mastra gives you more working defaults.
What is Mastra and who built it?
Mastra is an open-source TypeScript framework for AI agents and workflows, built by the team behind Gatsby and led by CEO Sam Bhagwat. It reached 1.0 on January 20, 2026, has about 29,000 GitHub stars, and has raised $35 million in total, including a $22 million Series A led by Spark Capital in April 2026.
Is Mastra free and open source?
The framework is Apache 2.0, except code in directories named ee/ (such as auth and the agent builder), which needs a Mastra Enterprise License for production use. The hosted Mastra platform has a free Starter tier, a Teams tier at $250 per month and custom Enterprise pricing (pricing). For comparison, LangChain.js and LangGraph.js are MIT, and LangSmith has a free Developer tier and a Plus tier at $39 per seat per month (pricing).
How does Mastra compare to Vercel AI SDK?
Vercel AI SDK is the integration layer for adding AI to React and Next.js apps, with streaming UI, multi-provider model access and, since version 7, durable agents through WorkflowAgent. Mastra is a full agent framework that builds on AI SDK model providers and adds workflows, memory, evals and Studio. Use AI SDK for AI features in an existing app; use Mastra for a standalone agent product.
What companies use Mastra in production?
Mastra names Brex, Indeed, Marsh McLennan (enterprise search used by more than 100,000 people daily), Replit, and platform teams at MongoDB, Workday and Salesforce in its Series A announcement. Replit’s Agent 3 builds Mastra agents for its users, and Mastra’s case study credits Mastra’s durable execution for raising workflow success from 80% to 96%.
