@mastra/deployer-netlify
v1.0.25
Published
A Netlify deployer for Mastra applications.
Maintainers
Keywords
Readme
@mastra/deployer-netlify
A Netlify deployer for Mastra applications.
Features
- Deploy Mastra applications to Netlify Functions
- Generates Netlify Frameworks API configuration during build
- Bundles functions with optimized settings for serverless environments
- Routes all requests through a single API endpoint
Installation
npm install @mastra/deployer-netlifyUsage
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(),
});Project Structure
The deployer automatically creates the following structure:
your-project/
└── .netlify/
└── v1/
├── config.json
└── functions/
└── api/
├── index.js
├── package.json
└── node_modules/Netlify Frameworks API Configuration
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:
- Tells Netlify where to find your functions
- Disables Netlify's bundling (Mastra pre-bundles for optimization)
- Routes all requests to your Mastra API function
How It Works
The Netlify deployer:
- Bundles your Mastra application into optimized serverless functions
- Creates the Frameworks API configuration automatically
- Handles all routing through a single API endpoint
- Pre-optimizes dependencies for serverless environments
Environment Variables
Environment variables are handled through:
.envfiles in your project- Netlify's environment variable dashboard
- Runtime environment variable access in your Mastra app
Deployment
Deploy your Mastra application to Netlify by:
- Building locally: Run your build command (the deployer handles bundling)
- Using Netlify CLI:
netlify deploy --prod - Via Git integration: Connect your repository to Netlify for automatic deployments
The deployer automatically configures everything needed for Netlify Functions.
