Serverless Deployment
Standalone Mastra applications can be deployed to popular serverless platforms using one of our deployer packages:
Deployers aren’t required when integrating Mastra with a framework. See Web Framework Integration for more information.
For self-hosted Node.js server deployment, see the Creating A Mastra Server guide.
Prerequisites
Before you begin, ensure you have:
- Node.js installed (version 18 or higher is recommended)
- If using a platform-specific deployer:
- An account with your chosen platform
- Required API keys or credentials
LibSQLStore
LibSQLStore
writes to the local filesystem, which is not supported in serverless environments due to their ephemeral nature. If you’re deploying to a platform like Vercel, Netlify or Cloudflare, you must remove all usage of LibSQLStore
.
Specifically, ensure you’ve removed it from both src/mastra/index.ts
and src/mastra/agents/weather-agent.ts
:
src/mastra/index.ts
export const mastra = new Mastra({
// ...
- storage: new LibSQLStore({
- // stores telemetry, evals, ... into memory storage, if it needs to persist, change to file:../mastra.db
- url: ":memory:",
- })
});
src/mastra/agents/weather-agent.ts
export const weatherAgent = new Agent({
// ..
- memory: new Memory({
- storage: new LibSQLStore({
- url: "file:../mastra.db" // path is relative to the .mastra/output directory
- })
- })
});