Mastra

Mastra

Freemium

The leading TypeScript framework for agents that run for days.

Agentic AI
Agent Frameworks

Published 27 September 2026

Scores

Popularity4/5

Over 27K GitHub stars and roughly 1M weekly npm downloads with adoption at Replit, Salesforce, and WorkOS mark it as the clear leader among TypeScript-first agent frameworks, though still smaller than the largest Python frameworks.

Learning Curve2/5

Typed agent and workflow configuration reads like idiomatic TypeScript, and JS/TS developers already familiar with Node.js tooling can get an agent running quickly without adopting a new mental model.

Flexibility4/5

Typed workflows with branching and retries, pluggable model routing, and MCP support cover most agent architectures, though the framework stays opinionated toward its own agent/workflow primitives rather than being fully unopinionated.

Performance4/5

Built-in evals, tracing, and metered CPU execution on Mastra Cloud are designed for production workloads that run continuously, backed by production deployments processing thousands of daily agent runs.

Portability4/5

Apache 2.0-licensed core is self-hostable anywhere Node.js runs and is provider-agnostic across 40+ model providers, though the managed Mastra Cloud layer and enterprise features introduce some pull toward the vendor's own platform.

About Mastra

Mastra is an open-source TypeScript framework for building AI agents, workflows, and retrieval-augmented applications, built by the team behind the Gatsby framework. It positions itself as the JavaScript-first alternative to Python-centric agent frameworks like LangChain and LlamaIndex, integrating directly into React, Next.js, and Node.js codebases or running as a standalone server, rather than bolting an AI layer onto an existing JS app from the outside.

Agents are defined with a typed configuration covering instructions, model, tools, and runtime behavior, so agent definitions get the same compile-time safety as the rest of a TypeScript codebase. Workflows compose typed steps with retries and branching for multi-stage automation, and a built-in memory system gives agents observational memory, semantic recall, and thread-aware storage that persists context across long-running sessions. Model access is standardized through routing across 40+ providers, including OpenAI, Anthropic, and Gemini, and agents can be exposed as Model Context Protocol (MCP) servers or consume external MCP tools.

Mastra ships with production-facing tooling out of the box: evals, metrics, traces, and datasets for monitoring agent quality and behavior over time, rather than treating observability as a separate integration. The core framework is Apache 2.0-licensed and free to self-host with no seat or usage limits; a managed Mastra Cloud platform adds hosted observability, CPU-metered execution, and enterprise controls (SSO, RBAC, VPC data isolation) on top, priced separately from the open-source library. Production users include Replit, Salesforce, Sanity, SoftBank, and WorkOS.

Key Features

  • Typed agent definitions: instructions, model, tools, and runtime behavior in one config
  • Workflow engine: typed steps, retries, and branching for multi-stage automation
  • Observational memory with semantic recall and thread-aware durable context
  • Standardized model routing across 40+ providers including OpenAI, Anthropic, and Gemini
  • Native Model Context Protocol (MCP) server authoring and consumption
  • Built-in evals, metrics, traces, and datasets for production observability

Pros

  • TypeScript-native design fits directly into existing React/Next.js/Node.js codebases
  • Apache 2.0-licensed core, free to self-host with no usage limits
  • Built-in observability (evals, traces, metrics) instead of a bolt-on integration
  • Backed by an experienced team (ex-Gatsby) and a well-funded YC-backed company

Cons

  • TypeScript/JavaScript-only, no path for Python-first teams
  • Younger ecosystem than LangChain/LlamaIndex, with fewer third-party integrations
  • Mastra Cloud pricing and enterprise features are separate from the open-source core
  • Smaller community and job-market footprint than the largest Python frameworks

Mastra Pricing

Freemium
Open SourceFree
  • · Apache 2.0-licensed framework, self-hosted anywhere Node.js runs
  • · Full agents, workflows, memory, and MCP support with no usage limits
Starter (Cloud)Free
  • · 100K observability events and 24 CPU hours included, then metered usage
  • · 15-day data retention, unlimited users, deployments, and projects
Teams$250/monthly
  • · 1M observability events and 250 CPU hours included, then metered usage
  • · 6-month data retention, multiple teams, SSO, and SOC 2 documentation
EnterpriseContact sales
  • · Custom volume, retention, RBAC, audit logs, uptime SLAs, and dedicated support
  • · VPC data isolation and flat annual pricing with no per-trace metering

Tech Stacks with Mastra

Next.js + PostgreSQL

Project

Full-stack Next.js app on PostgreSQL (self-managed or a serverless host like Neon), with Clerk, Auth0, or BetterAuth for auth, deployed to Vercel or a container host like Railway.

Frontend

Programming

Hosting

Authentication

Database:
ORM:
Auth:
Deploy on:
CI/CD add-on:
Containerization add-on:
Observability add-on:
Email add-on:
LLM add-on:
AI Agent add-on:
Payments add-on:
Styling add-on:
Analytics add-on:

TypeScript AI Agent

Project

A code-first AI agent in TypeScript. Next.js holds the agent and its chat interface in one app, a framework such as the Vercel AI SDK or Mastra runs the loop, PostgreSQL (your own, Neon, or Supabase) keeps the conversations, and a model such as Claude or OpenAI does the reasoning.

Agent Framework:
Database:
LLM:
Deploy on:
Authentication add-on:
Vector Database add-on:
LLM Observability add-on:
Code Sandbox add-on:
Model Aggregator add-on:
CI/CD add-on:
Containerization add-on:
Styling add-on:

Tools Related to Mastra

Works well with Mastra(4)

Next.js is Mastra's most common deployment target and has a dedicated official getting-started guide — agents and workflows typically run as Next.js API routes or server actions.

Mastra has an official SvelteKit getting-started guide for wiring agent and workflow calls into a SvelteKit app.

Mastra has an official Nuxt getting-started guide, covering the Vue ecosystem the same way its Next.js guide covers React.

Mastra has an official React + Vite getting-started guide for wiring agent and workflow calls into a React front end via the Mastra Client SDK.

Integrates with Mastra(5)

Mastra has an official Express getting-started guide and ships an Express server adapter for running Mastra routes inside an existing Express app.

Mastra ships a first-party @mastra/nestjs server adapter — a dedicated NestJS module that registers Mastra's agent and workflow routes inside an existing NestJS application.

Mastra ships a first-party OpenAI provider as part of its standardized model routing layer, for running agents on OpenAI models.

Mastra ships a first-party Anthropic provider as part of its standardized model routing layer, for running agents on Claude models.

Mastra ships a first-party Google provider as part of its standardized model routing layer, for running agents on Gemini models.

Alternatives to Mastra(8)

Mastra is built on the Vercel AI SDK's model layer and adds workflows, memory, and evals on top; the AI SDK alone is the lighter option for streaming and tool calls. Pick the AI SDK for focused features, Mastra for a full agent framework.

Both are agent frameworks for building multi-step, tool-using agents — CrewAI centres on role-based multi-agent crews in Python, Mastra on typed agents and workflows in TypeScript. Teams pick one as their primary framework.

Mastra positions itself as the TypeScript-first alternative to LangChain, covering the same RAG, memory, and multi-agent workflow ground with typed, JS-native primitives instead of LangChain's Python-first component library.

Both frameworks let developers hand-build multi-step agent workflows with explicit control flow — LangGraph as a Python state-graph runtime, Mastra as a typed TypeScript workflow engine.

Both are type-safe, production-oriented agent frameworks built around strict typing — Pydantic AI for Python teams, Mastra for TypeScript teams. Competing picks depending on backend language.

The OpenAI Agents SDK is Python-first with a TypeScript port that trails it; Mastra is built for TypeScript from the start, with workflows, memory, and RAG included. The choice mostly follows the team's language.

Vendor

Tags

TypeScriptOpen SourceSelf-hostableFree TierAI-poweredWorkflow Automation

Details

Maintained
Yes
Agent type
Framework
Primary language
TypeScript
Open source
Yes
Hosting
Self-hosted
GitHub stars
28.3k
Stars updated
2026-09-23