VercelDeployer
The VercelDeployer bundles your Mastra server and generates output conforming to Vercel's Build Output API. Vercel deploys this output directly as serverless functions.
InstallationDirect link to Installation
To use VercelDeployer, install the @mastra/deployer-vercel package:
- npm
- pnpm
- Yarn
- Bun
npm install @mastra/deployer-vercel@latest
pnpm add @mastra/deployer-vercel@latest
yarn add @mastra/deployer-vercel@latest
bun add @mastra/deployer-vercel@latest
Usage exampleDirect link to Usage example
Import VercelDeployer and set it as the deployer in your Mastra configuration:
import { Mastra } from "@mastra/core";
import { VercelDeployer } from "@mastra/deployer-vercel";
export const mastra = new Mastra({
deployer: new VercelDeployer(),
});
Constructor optionsDirect link to Constructor options
The deployer accepts overrides that are written to the Vercel Output API function config (.vc-config.json):
maxDuration?: number— Function execution timeout (in seconds)memory?: number— Function memory (in MB)regions?: string[]— Regions to deploy the function (e.g.['sfo1','iad1'])
These options are merged into .vercel/output/functions/index.func/.vc-config.json while preserving default fields (handler, launcherType, runtime, shouldAddHelpers).
Example with overridesDirect link to Example with overrides
import { Mastra } from "@mastra/core";
import { VercelDeployer } from "@mastra/deployer-vercel";
export const mastra = new Mastra({
deployer: new VercelDeployer({
maxDuration: 600,
memory: 1536,
regions: ["sfo1", "iad1"],
}),
});
Build outputDirect link to Build output
After running mastra build, the deployer generates a .vercel/output directory conforming to Vercel's Build Output API (v3). This directory contains routing configuration and serverless function bundles that Vercel deploys directly, bypassing framework detection.
The output contains:
- config.json — Routing configuration that directs all requests to your function
- functions/ — Your Mastra server bundled as a serverless function
.vercel/
└── output/
├── config.json
└── functions/
└── index.func/
├── .vc-config.json
├── index.mjs
└── node_modules/
This folder is generated during build and should not be committed to version control.