Prerequisites:
- A Vercel account
- Node.js version 22 or higher
- A Mastra project ready to deploy
Installation
Build your project
Run your build command. The deployer will create the Vercel Build Output structure:This generates:
.vercel/output/functions/index.func/- Your bundled function.vercel/output/config.json- Routing configuration.vercel/output/functions/index.func/.vc-config.json- Function settings
Configuration options
TheVercelDeployer constructor accepts the following options (all optional):
maxDuration
- Type:
number - Description: Maximum function execution time in seconds
- Default: Depends on your Vercel plan
- Example:
maxDuration: 300for 5 minutes
memory
- Type:
number - Description: Function memory allocation in MB
- Default:
1024 - Example:
memory: 3008for maximum memory
regions
- Type:
string[] - Description: Vercel regions where the function should be deployed
- Default: All regions
- Example:
regions: ['iad1', 'sfo1']
These options are written to
.vercel/output/functions/index.func/.vc-config.json and override Vercel’s defaults.How it works
The Vercel deployer:- Bundles your application using Rollup with optimizations
- Creates an entry point using Hono’s Vercel adapter:
- Generates Vercel configuration for routing and function settings
- Detects Node.js version automatically from your environment
Storage compatibility
Use these storage options instead:@mastra/pg- PostgreSQL (recommended)@mastra/mongodb- MongoDB@mastra/dynamodb- AWS DynamoDB
Environment variables
Environment variables can be configured in multiple ways:- Local
.envfiles - Automatically loaded during development - Vercel Dashboard - Set in your project settings
- Vercel CLI - Use
vercel envcommands
Project structure
After building, your project will have this structure:Troubleshooting
Build fails with 'Cannot find module' error
Build fails with 'Cannot find module' error
Make sure all dependencies are listed in your
package.json. The deployer bundles your code but dependencies need to be properly declared.Function times out
Function times out
Increase the Note: Maximum duration depends on your Vercel plan.
maxDuration option:Error: @libsql/client not supported
Error: @libsql/client not supported
The deployer automatically detects
@mastra/libsql and throws an error. Switch to @mastra/pg or another compatible storage option.Next steps
Server & API
Learn about Mastra’s server capabilities
Storage options
Explore compatible storage backends
Environment setup
Configure middleware and environment
Observability
Set up logging and tracing