NetlifyDeployer
The NetlifyDeployer deploys Mastra applications to Netlify Functions, handling site creation, configuration, and deployment processes. It extends the abstract Deployer class to provide Netlify-specific deployment functionality.
Usage Example
import { Mastra } from '@mastra/core';
import { NetlifyDeployer } from '@mastra/deployer-netlify';
const mastra = new Mastra({
deployer: new NetlifyDeployer({
scope: 'your-team-slug',
projectName: 'your-project-name',
token: 'your-netlify-token'
}),
// ... other Mastra configuration options
});
Parameters
Constructor Parameters
scope:
string
Your Netlify team slug or ID.
projectName:
string
Name of your Netlify site (will be created if it doesn't exist).
token:
string
Your Netlify authentication token.
Netlify Configuration
The NetlifyDeployer automatically generates a netlify.toml
configuration file with the following settings:
[functions]
node_bundler = "esbuild"
directory = "netlify/functions"
[[redirects]]
force = true
from = "/*"
status = 200
to = "/.netlify/functions/api/:splat"
Environment Variables
The NetlifyDeployer handles environment variables from multiple sources:
- Environment Files: Variables from
.env.production
and.env
files. - Configuration: Variables passed through the Mastra configuration.
- Netlify Dashboard: Variables can also be managed through Netlify’s web interface.
Project Structure
The deployer creates the following structure in your output directory:
output-directory/
├── netlify/
│ └── functions/
│ └── api/
│ └── index.mjs # Application entry point with Hono server integration
└── netlify.toml # Deployment configuration