Skip to main content

VercelDeployer

VercelDeployer 类负责将独立的 Mastra 应用部署到 Vercel。它管理配置和部署,并在基础 Deployer 类的基础上扩展了 Vercel 特有的功能。

🌐 The VercelDeployer class handles deployment of standalone Mastra applications to Vercel. It manages configuration, deployment, and extends the base Deployer class with Vercel specific functionality.

使用示例
Direct link to 使用示例

🌐 Usage example

src/mastra/index.ts
import { Mastra } from "@mastra/core";
import { VercelDeployer } from "@mastra/deployer-vercel";

export const mastra = new Mastra({
deployer: new VercelDeployer(),
});

构造函数选项
Direct link to 构造函数选项

🌐 Constructor options

部署工具支持一小部分高价值的覆盖项,这些覆盖项会写入 Vercel 输出 API 函数配置(.vc-config.json):

🌐 The deployer supports a small set of high‑value overrides that are written to the Vercel Output API function config (.vc-config.json):

  • maxDuration?: number — 函数执行超时(秒)
  • memory?: number — 函数内存(MB)
  • regions?: string[] — 部署该功能的区域(例如 ['sfo1','iad1']

这些选项被合并到 .vercel/output/functions/index.func/.vc-config.json,同时保留默认字段(handlerlauncherTyperuntimeshouldAddHelpers)。

🌐 These options are merged into .vercel/output/functions/index.func/.vc-config.json while preserving default fields (handler, launcherType, runtime, shouldAddHelpers).

带覆盖的示例
Direct link to 带覆盖的示例

🌐 Example with overrides

src/mastra/index.ts
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"],
}),
});