Skip to main content
Mastra 1.0 is available 🎉 Read announcement

Deployment

Deploy your Mastra application to production and expose your agents, tools, and workflows as REST API endpoints.

info

Mastra Cloud is currently in beta, but many teams are already using it to deploy their agents. It's the easiest way to run Mastra agents in a managed environment.

Enable deployments
Direct link to Enable deployments

After setting up your project, click Deployment in the sidebar and select Enable Deployments.

Once enabled, your project automatically builds and deploys. Future pushes to your main branch trigger automatic redeployments.

Dashboard
Direct link to Dashboard

The Overview page shows your project's domain URL, status, latest deployment, and connected agents and workflows.

Project dashboard

Click the Deployments menu item to view build logs. Open Settings to configure environment variables, branch, storage, and endpoint URLs.

note

Changes to settings require a new deployment to take effect

Storage configuration
Direct link to Storage configuration

Mastra Cloud offers two storage options:

  1. Mastra Cloud Store: Managed storage provided by Mastra Cloud
  2. Bring your own database: Connect to your own external database

Using Mastra Cloud Store
Direct link to Using Mastra Cloud Store

When using the managed Mastra Cloud Store (enabled in your project settings), storage must be configured on the Mastra instance, not on individual agent Memory instances.

Configure storage on your Mastra instance:

src/mastra/index.ts
import { Mastra } from "@mastra/core";
import { LibSQLStore } from "@mastra/libsql";

export const mastra = new Mastra({
storage: new LibSQLStore({
id: "mastra-store",
url: "file:./mastra.db",
}),
agents: { myAgent },
});

Agents can use Memory without specifying storage as they inherit from the Mastra instance:

src/mastra/agents/my-agent.ts
import { Agent } from "@mastra/core/agent";
import { Memory } from "@mastra/memory";

export const myAgent = new Agent({
id: "my-agent",
memory: new Memory({
// No storage here - uses instance-level storage from Mastra Cloud Store
options: {
lastMessages: 20,
},
}),
});

Bring your own database
Direct link to Bring your own database

If you don't use Mastra Cloud Store, you can use any storage provider with any configuration. Set your database connection strings as environment variables in your project's Settings page.

Using your deployment
Direct link to Using your deployment

After deployment, interact with your agents using the Mastra Client or call the REST API endpoints directly.

Next steps
Direct link to Next steps