Skip to main content

Prerequisites

Before installing Mastra, ensure you have the following:
  • Node.js version 22.13.0 or higher
  • A package manager: npm, pnpm, or yarn
Mastra requires Node.js >= 22.13.0 to take advantage of the latest TypeScript and JavaScript features.
The fastest way to get started with Mastra is using the create command:
1

Run the create command

Open your terminal and run:
npm create mastra@latest
This interactive CLI will guide you through the setup process.
2

Follow the prompts

The CLI will ask you to:
  • Choose a project name
  • Select a template (starter, agent, workflow, etc.)
  • Choose your preferred package manager
  • Configure optional features
3

Navigate to your project

cd your-project-name
4

Install dependencies

If not already installed by the CLI:
npm install
5

Start developing

You’re ready to build! Check out the Quickstart guide to create your first agent.

Manual Installation

If you prefer to add Mastra to an existing project:
1

Install the core package

npm install @mastra/core
2

Install AI SDK providers

Install the AI SDK providers you want to use:
npm install @ai-sdk/openai @ai-sdk/anthropic
3

Install Zod for schema validation

npm install zod
4

(Optional) Install storage adapter

For persistence, install a storage adapter like LibSQL:
npm install @mastra/libsql

Verify Installation

Create a simple test file to verify your installation:
test.ts
import { Mastra } from '@mastra/core/mastra';

const mastra = new Mastra({});

console.log('Mastra initialized successfully!');
Run it:
npx tsx test.ts
If you see the success message, you’re ready to go!

Next Steps

Quickstart

Build your first AI agent in minutes

Core Concepts

Learn the fundamentals of Mastra

Troubleshooting

Make sure you’re using Node.js version 22.13.0 or higher:
node --version
If needed, update Node.js using nvm or download from nodejs.org.
Ensure all peer dependencies are installed, especially zod:
npm install zod

Build docs developers (and LLMs) love