Skip to main content
Mastra provides deployer packages that help you deploy your AI applications to different serverless platforms. Each deployer handles the build configuration, bundling, and deployment-specific optimizations for its target platform.

Available deployers

Mastra supports deployment to the following platforms:

Vercel

Deploy to Vercel with zero-config serverless functions

Cloudflare Workers

Deploy to Cloudflare’s edge network for global performance

Netlify

Deploy to Netlify Functions with automatic configuration

How deployers work

Mastra deployers extend the base Deployer class from @mastra/deployer and provide platform-specific functionality:
  1. Bundling - Creates optimized bundles for the target platform
  2. Configuration - Generates platform-specific config files
  3. Environment handling - Manages environment variables
  4. Dependency management - Installs and optimizes dependencies
  5. Deployment output - Structures files for deployment

Basic usage

All deployers follow a similar pattern:
import { Mastra } from '@mastra/core/mastra';
import { VercelDeployer } from '@mastra/deployer-vercel';
// Or: import { CloudflareDeployer } from '@mastra/deployer-cloudflare';
// Or: import { NetlifyDeployer } from '@mastra/deployer-netlify';

const deployer = new VercelDeployer({
  // Platform-specific options
});

const mastra = new Mastra({
  deployer,
  // ... other Mastra configuration
});

Storage compatibility

Different platforms have different runtime constraints. Here’s a compatibility matrix for storage options:
StorageVercelCloudflareNetlify
@mastra/pg (PostgreSQL)
@mastra/libsql
@mastra/cloudflare-d1
@mastra/mongodb
@mastra/dynamodb
@mastra/libsql uses native Node.js bindings that cannot run in serverless environments. Use platform-specific alternatives like @mastra/cloudflare-d1 for Cloudflare Workers or @mastra/pg for other platforms.

Environment variables

All deployers automatically handle environment variables:
  • Reads from .env files in your project
  • Merges with user-provided configuration
  • Platform-specific env var UI (Vercel, Cloudflare, Netlify dashboards)

Build output

Each deployer creates a platform-specific build directory:
  • Vercel: .vercel/output/functions/
  • Cloudflare: Creates wrangler.jsonc in project root
  • Netlify: .netlify/v1/functions/
The build artifacts are automatically generated when you run your deployment command. You don’t need to commit these directories to version control.

Next steps

Choose your deployment platform and follow the step-by-step guide:

Deploy to Vercel

Step-by-step Vercel deployment

Deploy to Cloudflare

Step-by-step Cloudflare deployment

Deploy to Netlify

Step-by-step Netlify deployment

Build docs developers (and LLMs) love