> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # NetlifyDeployer `NetlifyDeployer` クラスは、Mastra の出力を調整して最適化されたサーバーを作成し、パッケージ化、設定、デプロイを処理します。基底クラスの [`Deployer`](https://mastra.zisheng.pro/ja/reference/deployer) を Netlify 固有の機能で拡張しています。これにより、Netlify のサーバーレス関数または Edge Functions 内で Mastra を実行できます。 ## インストール `NetlifyDeployer` を使用するには、`@mastra/deployer-netlify` パッケージをインストールする必要があります。 **npm**: ```bash npm install @mastra/deployer-netlify@latest ``` **pnpm**: ```bash pnpm add @mastra/deployer-netlify@latest ``` **Yarn**: ```bash yarn add @mastra/deployer-netlify@latest ``` **Bun**: ```bash bun add @mastra/deployer-netlify@latest ``` ## 使用例 `NetlifyDeployer` をインポートし、Mastra 設定で deployer に指定します。 ```typescript import { Mastra } from '@mastra/core' import { NetlifyDeployer } from '@mastra/deployer-netlify' export const mastra = new Mastra({ deployer: new NetlifyDeployer(), }) ``` ## コンストラクターオプション - `target?: 'serverless' | 'edge'`:Netlify のデプロイ先です。デフォルトは `'serverless'` です。 - `'serverless'`:標準の [Netlify Functions](https://docs.netlify.com/functions/overview/)(Node.js ランタイム、デフォルトのタイムアウトは 60 秒)。 - `'edge'`:[Netlify Edge Functions](https://docs.netlify.com/build/edge-functions/overview/)(Deno ベースのランタイムで、ユーザーに最も近いエッジで実行され、固定のタイムアウトはありません)。 ### Edge Functions の例 ```typescript import { Mastra } from '@mastra/core' import { NetlifyDeployer } from '@mastra/deployer-netlify' export const mastra = new Mastra({ deployer: new NetlifyDeployer({ target: 'edge', }), }) ``` ## 出力 `mastra build` を実行すると、deployer は `.netlify` フォルダーを生成します。ビルド出力にはプロジェクトのすべての Agent、Tool、Workflow に加え、[Netlify Frameworks API](https://docs.netlify.com/build/frameworks/frameworks-api/) を設定する `config.json` ファイルが含まれます。 ### サーバーレス出力(デフォルト) ```bash your-project/ └── .netlify/ └── v1/ ├── config.json └── functions/ └── api/ ├── index.mjs ├── package.json └── node_modules/ ``` `config.json` ファイルの内容は次のとおりです。 ```json { "functions": { "directory": ".netlify/v1/functions", "node_bundler": "none", "included_files": [".netlify/v1/functions/**"] }, "redirects": [ { "force": true, "from": "/*", "to": "/.netlify/functions/api/:splat", "status": 200 } ] } ``` ### Edge 出力 ```bash your-project/ └── .netlify/ └── v1/ ├── config.json └── edge-functions/ ├── index.mjs ├── package.json └── node_modules/ ``` `config.json` ファイルの内容は次のとおりです。 ```json { "edge_functions": [ { "function": "index", "path": "/*" } ] } ```