A Netlify deployer for Mastra applications.
- Deploy Mastra applications to Netlify Functions
- Automatic site creation and configuration
- Serverless function support with Edge Functions
- Zero-configuration deployments
pnpm add @mastra/deployer-netlify
The Netlify deployer is used as part of the Mastra framework:
import { Mastra } from '@mastra/core';
import { NetlifyDeployer } from '@mastra/deployer-netlify';
const deployer = new NetlifyDeployer({
scope: 'your-team-id',
projectName: 'your-project-name',
token: 'your-netlify-token',
});
const mastra = new Mastra({
deployer,
// ... other Mastra configuration options
});
-
scope
(required): Your Netlify team slug or ID -
projectName
: Name of your Netlify site (will be created if it doesn't exist) -
token
: Your Netlify authentication token
The deployer automatically creates the following structure:
your-project/
├── netlify/
│ └── functions/
│ └── api/
└── netlify.toml
The deployer creates a netlify.toml
with the following defaults:
[functions]
node_bundler = "esbuild"
directory = "/netlify/functions"
[[redirects]]
force = true
from = "/*"
status = 200
to = "/.netlify/functions/api/:splat"
Environment variables are handled automatically through:
-
.env
files in your project - Environment variables passed through the Mastra configuration
- Netlify's environment variable UI
The deployer will:
- Create a new site if it doesn't exist
- Configure the site with your environment variables
- Deploy your application to Netlify Functions