deployers/netlify/README.md
A Netlify deployer for Mastra applications.
npm install @mastra/deployer-netlify
The Netlify deployer is used as part of the Mastra framework:
import { Mastra } from '@mastra/core/mastra';
import { NetlifyDeployer } from '@mastra/deployer-netlify';
const mastra = new Mastra({
deployer: new NetlifyDeployer(),
});
The deployer automatically creates the following structure:
your-project/
└── .netlify/
└── v1/
├── config.json
└── functions/
└── api/
├── index.js
├── package.json
└── node_modules/
The deployer uses Netlify's Frameworks API and generates a .netlify/v1/config.json file to configure functions and routing for Netlify.
Generated configuration:
{
"functions": {
"directory": ".netlify/v1/functions",
"node_bundler": "none",
"included_files": [".netlify/v1/functions/**"]
},
"redirects": [
{
"force": true,
"from": "/*",
"to": "/.netlify/functions/api/:splat",
"status": 200
}
]
}
This configuration:
The Netlify deployer:
Environment variables are handled through:
.env files in your projectDeploy your Mastra application to Netlify by:
netlify deploy --prodThe deployer automatically configures everything needed for Netlify Functions.