# NetlifyDeployer The `NetlifyDeployer` class handles deployment of standalone Mastra applications to Netlify. It manages configuration, deployment, and extends the base [Deployer](https://mastra.ai/reference/deployer/llms.txt) class with Netlify specific functionality. Netlify Functions use an ephemeral filesystem. Remove any usage of [LibSQLStore](https://mastra.ai/reference/storage/libsql/llms.txt) with file URLs from your Mastra configuration. Use in-memory storage (`:memory:`) or external storage providers like Turso, PostgreSQL, or Upstash. ## Installation ```bash npm install @mastra/deployer-netlify@latest ``` ```bash pnpm add @mastra/deployer-netlify@latest ``` ```bash yarn add @mastra/deployer-netlify@latest ``` ```bash bun add @mastra/deployer-netlify@latest ``` ## Usage example ```typescript import { Mastra } from "@mastra/core"; import { NetlifyDeployer } from "@mastra/deployer-netlify"; export const mastra = new Mastra({ deployer: new NetlifyDeployer(), }); ``` > See the [NetlifyDeployer](https://mastra.ai/reference/deployer/netlify/llms.txt) API reference for all available configuration options. ## Continuous integration After connecting your Mastra project’s Git repository to Netlify, update the project settings. In the Netlify dashboard, go to **Project configuration** > **Build & deploy** > **Continuous deployment**, and under **Build settings**, set the following: - **Build command**: `npm run build` (optional) ### Environment variables Before your first deployment, make sure to add any environment variables used by your application. For example, if you're using OpenAI as the LLM, you'll need to set `OPENAI_API_KEY` in your Netlify project settings. > See [Environment variables overview](https://docs.netlify.com/environment-variables/overview/) for more details. Your project is now configured with automatic deployments which occur whenever you push to the configured branch of your GitHub repository. ## Manual deployment Manual deployments are also possible using the [Netlify CLI](https://docs.netlify.com/cli/get-started/). With the Netlify CLI installed run the following from your project root to deploy your application. You can also run `netlify dev` from your project root to test your Mastra application locally. ```bash netlify deploy --prod ``` When using `netlify deploy` instead of continuous deployment, you need to create a `netlify.toml` file with these contents: ```toml [build] command = "npm run build" publish = ".netlify/v1/functions" [functions] directory = ".netlify/v1/functions" node_bundler = "none" included_files = [".netlify/v1/functions/**"] [[redirects]] from = "/*" to = "/.netlify/functions/api/:splat" status = 200 [build.environment] NODE_VERSION = "22.13.0" ``` Adjust the `build.command` to your project. ## Build output The build output for Mastra applications using the `NetlifyDeployer` includes all agents, tools, and workflows in your project, along with Mastra-specific files required to run your application on Netlify. ```bash your-project/ └── .netlify/ └── v1/ ├── config.json └── functions/ └── api/ ├── index.js ├── package.json └── node_modules/ ``` The `NetlifyDeployer` automatically generates a `config.json` configuration file in `.netlify/v1` with the following settings: ```json { "functions": { "directory": ".netlify/v1/functions", "node_bundler": "none", "included_files": [".netlify/v1/functions/**"] }, "redirects": [ { "force": true, "from": "/*", "to": "/.netlify/functions/api/:splat", "status": 200 } ] } ``` ## Next steps - [Mastra Client SDK](https://mastra.ai/reference/client-js/mastra-client/llms.txt)