> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # VercelDeployer `VercelDeployer` は Mastra サーバーをバンドルし、Vercel の [Build Output API](https://vercel.com/docs/build-output-api/v3) に準拠した出力を生成します。Vercel はこの出力をサーバーレス関数として直接デプロイします。 ## インストール `VercelDeployer` を使用するには、`@mastra/deployer-vercel` パッケージをインストールします。 **npm**: ```bash npm install @mastra/deployer-vercel@latest ``` **pnpm**: ```bash pnpm add @mastra/deployer-vercel@latest ``` **Yarn**: ```bash yarn add @mastra/deployer-vercel@latest ``` **Bun**: ```bash bun add @mastra/deployer-vercel@latest ``` ## 使用例 `VercelDeployer` をインポートし、Mastra 設定で deployer に指定します。 ```typescript import { Mastra } from '@mastra/core' import { VercelDeployer } from '@mastra/deployer-vercel' export const mastra = new Mastra({ deployer: new VercelDeployer(), }) ``` ## コンストラクターオプション deployer は次のオプションを受け取ります。 - `studio?: boolean`:API とともに [Studio](https://mastra.zisheng.pro/ja/docs/studio/overview) を、Vercel の Edge CDN から配信される静的アセットとしてデプロイします。デフォルトは `false` です。 - `maxDuration?: number`:関数の実行タイムアウト(秒) - `memory?: number`:関数のメモリ(MB) - `regions?: string[]`:関数をデプロイするリージョン(例:`['sfo1','iad1']`) `maxDuration`、`memory`、`regions` オプションは、デフォルトフィールド(`handler`、`launcherType`、`runtime`、`shouldAddHelpers`)を保持したまま `.vercel/output/functions/index.func/.vc-config.json` にマージされます。 ### オーバーライドの例 ```typescript import { Mastra } from '@mastra/core' import { VercelDeployer } from '@mastra/deployer-vercel' export const mastra = new Mastra({ deployer: new VercelDeployer({ studio: true, maxDuration: 600, memory: 1536, regions: ['sfo1', 'iad1'], }), }) ``` ## ビルド出力 `mastra build` を実行すると、deployer は Vercel の [Build Output API (v3)](https://vercel.com/docs/build-output-api/v3) に準拠した `.vercel/output` ディレクトリを生成します。このディレクトリには、Vercel がフレームワーク検出を介さずに直接デプロイするルーティング設定とサーバーレス関数バンドルが含まれます。 出力には次のものが含まれます。 - **config.json**:リクエストを適切なハンドラーへ振り分けるルーティング設定 - **functions/**:サーバーレス関数としてバンドルされた Mastra サーバー - **static/**:Studio SPA のアセット(`studio: true` の場合のみ) Studio を含めない場合: ```bash .vercel/ └── output/ ├── config.json └── functions/ └── index.func/ ├── .vc-config.json ├── index.mjs └── node_modules/ ``` `studio: true` の場合: ```bash .vercel/ └── output/ ├── config.json ├── static/ │ ├── index.html │ └── assets/ │ ├── *.js │ └── *.css └── functions/ └── index.func/ ├── .vc-config.json ├── index.mjs └── node_modules/ ``` Studio が有効な場合、`/api/*` リクエストはサーバーレス関数によって処理され、静的アセット(JS、CSS)は関数を呼び出さずに Vercel の Edge CDN から配信されます。それ以外のすべてのパスは、クライアント側ルーティングのために `index.html` へフォールバックするよう設定されます。 このフォルダーはビルド時に生成されるため、バージョン管理にコミットしないでください。