PageSourceSearch

https://mastra.ai/assets/js/d9c5d812.64ab03da.js

js mastra.ai collected 2026-09-24 17:16:47 UTC 13,243 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkmastra_docs=self.webpackChunkmastra_docs||[]).push([["24680"],{24360(e,n,t){t.r(n),t.d(n,{metadata:()=>r,default:()=>f,frontMatter:()=>i,contentTitle:()=>c,toc:()=>d,assets:()=>u});var r=JSON.parse('{"id":"deployer/netlify","title":"Reference: NetlifyDeployer | Deployer","description":"The NetlifyDeployer class handles packaging, configuration, and deployment by adapting Mastra\'s output to create an optimized version of your server.","source":"@site/src/content/en/reference/deployer/netlify.mdx","sourceDirName":"deployer","slug":"/deployer/netlify","permalink":"/reference/deployer/netlify","draft":false,"unlisted":false,"editUrl":"https://github.com/mastra-ai/mastra/tree/main/docs/src/content/en/reference/deployer/netlify.mdx","tags":[],"version":"current","frontMatter":{"title":"Reference: NetlifyDeployer | Deployer","description":"The NetlifyDeployer class handles packaging, configuration, and deployment by adapting Mastra\'s output to create an optimized version of your server.","packages":["@mastra/deployer-netlify"]},"sidebar":"referenceSidebar","previous":{"title":"Deployer","permalink":"/reference/deployer/"},"next":{"title":"Vercel","permalink":"/reference/deployer/vercel"}}'),a=t(74848),l=t(28453),s=t(50580),o=t(57250);let i={title:"Reference: NetlifyDeployer | Deployer",description:"The NetlifyDeployer class handles packaging, configuration, and deployment by adapting Mastra's output to create an optimized version of your server.",packages:["@mastra/deployer-netlify"]},c="NetlifyDeployer",u={},d=[{value:"Installation",id:"installation",level:2},{value:"Usage example",id:"usage-example",level:2},{value:"Constructor options",id:"constructor-options",level:2},{value:"Edge functions example",id:"edge-functions-example",level:3},{value:"Output",id:"output",level:2},{value:"Serverless output (default)",id:"serverless-output-default",level:3},{value:"Edge output",id:"edge-output",level:3}];function p(e){let n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,l.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.header,{children:(0,a.jsx)(n.h1,{id:"netlifydeployer",children:"NetlifyDeployer"})}),"\n",(0,a.jsxs)(n.p,{children:["The ",(0,a.jsx)(n.code,{children:"NetlifyDeployer"})," class handles packaging, configuration, and deployment by adapting Mastra's output to create an optimized version of your server. It extends the base ",(0,a.jsx)(n.a,{href:"/reference/deployer/",children:(0,a.jsx)(n.code,{children:"Deployer"})})," class with Netlify-specific functionality. It enables you to run Mastra within Netlify serverless functions or edge functions."]}),"\n",(0,a.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,a.jsxs)(n.p,{children:["To use ",(0,a.jsx)(n.code,{children:"NetlifyDeployer"}),", you need to install the ",(0,a.jsx)(n.code,{children:"@mastra/deployer-netlify"})," package:"]}),"\n",(0,a.jsxs)(s.A,{groupId:"npm2yarn",children:[(0,a.jsx)(o.A,{value:"npm",children:(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-bash",children:"npm install @mastra/deployer-netlify@latest\n"})})}),(0,a.jsx)(o.A,{value:"pnpm",label:"pnpm",children:(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-bash",children:"pnpm add @mastra/deployer-netlify@latest\n"})})}),(0,a.jsx)(o.A,{value:"yarn",label:"Yarn",children:(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-bash",children:"yarn add @mastra/deployer-netlify@latest\n"})})}),(0,a.jsx)(o.A,{value:"bun",label:"Bun",children:(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-bash",children:"bun add @mastra/deployer-netlify@latest\n"})})})]}),"\n",(0,a.jsx)(n.h2,{id:"usage-example",children:"Usage example"}),"\n",(0,a.jsxs)(n.p,{children:["Import ",(0,a.jsx)(n.code,{children:"NetlifyDeployer"})," and set it as the deployer in your Mastra configuration:"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-typescript",metastring:'title="src/mastra/index.ts"',children:"import { Mastra } from '@mastra/core'\n// highlight-next-line\nimport { NetlifyDeployer }
1 from '@mastra/deployer-netlify'\n\nexport const mastra = new Mastra({\n  // highlight-next-line\n  deployer: new NetlifyDeployer(),\n})\n"})}),"\n",(0,a.jsx)(n.h2,{id:"constructor-options",children:"Constructor options"}),"\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsxs)(n.li,{children:[(0,a.jsx)(n.code,{children:"target?: 'serverless' | 'edge'"}),": Deploy target for Netlify. Defaults to ",(0,a.jsx)(n.code,{children:"'serverless'"}),".","\n",(0,a.jsxs)(n.ul,{children:["\n",(0,a.jsxs)(n.li,{children:[(0,a.jsx)(n.code,{children:"'serverless'"}),": Standard ",(0,a.jsx)(n.a,{href:"https://docs.netlify.com/functions/overview/",children:"Netlify Functions"})," (Node.js runtime, 60s default timeout)."]}),"\n",(0,a.jsxs)(n.li,{children:[(0,a.jsx)(n.code,{children:"'edge'"}),": ",(0,a.jsx)(n.a,{href:"https://docs.netlify.com/build/edge-functions/overview/",children:"Netlify Edge Functions"})," (Deno-based runtime that runs at the edge closest to users without a fixed timeout)."]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,a.jsx)(n.h3,{id:"edge-functions-example",children:"Edge functions example"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-typescript",metastring:'title="src/mastra/index.ts"',children:"import { Mastra } from '@mastra/core'\nimport { NetlifyDeployer } from '@mastra/deployer-netlify'\n\nexport const mastra = new Mastra({\n  deployer: new NetlifyDeployer({\n    target: 'edge',\n  }),\n})\n"})}),"\n",(0,a.jsx)(n.h2,{id:"output",children:"Output"}),"\n",(0,a.jsxs)(n.p,{children:["After running ",(0,a.jsx)(n.code,{children:"mastra build"}),", the deployer generates a ",(0,a.jsx)(n.code,{children:".netlify"})," folder. The build output includes all agents, tools, and workflows of your project, alongside a ",(0,a.jsx)(n.code,{children:"config.json"})," file that configures the ",(0,a.jsx)(n.a,{href:"https://docs.netlify.com/build/frameworks/frameworks-api/",children:"Netlify Frameworks API"}),"."]}),"\n",(0,a.jsx)(n.h3,{id:"serverless-output-default",children:"Serverless output (default)"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-bash",children:"your-project/\n\u2514\u2500\u2500 .netlify/\n    \u2514\u2500\u2500 v1/\n        \u251C\u2500\u2500 config.json\n        \u2514\u2500\u2500 functions/\n            \u2514\u2500\u2500 api/\n                \u251C\u2500\u2500 index.mjs\n                \u251C\u2500\u2500 package.json\n                \u2514\u2500\u2500 node_modules/\n"})}),"\n",(0,a.jsxs)(n.p,{children:["The ",(0,a.jsx)(n.code,{children:"config.json"})," file contains:"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-json",children:'{\n  "functions": {\n    "directory": ".netlify/v1/functions",\n    "node_bundler": "none",\n    "included_files": [".netlify/v1/functions/**"]\n  },\n  "redirects": [\n    {\n      "force": true,\n      "from": "/*",\n      "to": "/.netlify/functions/api/:splat",\n      "status": 200\n    }\n  ]\n}\n'})}),"\n",(0,a.jsx)(n.h3,{id:"edge-output",children:"Edge output"}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-bash",children:"your-project/\n\u2514\u2500\u2500 .netlify/\n    \u2514\u2500\u2500 v1/\n        \u251C\u2500\u2500 config.json\n        \u2514\u2500\u2500 edge-functions/\n            \u251C\u2500\u2500 index.mjs\n            \u251C\u2500\u2500 package.json\n            \u2514\u2500\u2500 node_modules/\n"})}),"\n",(0,a.jsxs)(n.p,{children:["The ",(0,a.jsx)(n.code,{children:"config.json"})," file contains:"]}),"\n",(0,a.jsx)(n.pre,{children:(0,a.jsx)(n.code,{className:"language-json",children:'{\n  "edge_functions": [\n    {\n      "function": "index",\n      "path": "/*"\n    }\n  ]\n}\n'})})]})}function f(e={}){let{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,a.jsx)(n,{...e,children:(0,a.jsx)(p,{...e})}):p(e)}},57250(e,n,t){t.d(n,{A:()=>o});var r=t(74848);t(96540);var a=t(34164),l=t(57663);function s({children:e,className:n,hidden:t}){return(0,r.jsx)("div",{role:"tabpanel",className:(0,a.A)("tabItem_Ymn6",n),hidden:t,children:e})}function o({children:e,className:n,value:t}){let{selectedValue:a,lazy:i}=(0,l.uc)(),c=t===a;return!c&&i?null:(0,r.jsx)(s,{className:n,hidden:!c,children:e})}},57663(e,n,t){t.d(n,{OC:()=>p,O_:()=>y,uc:()=>h,vT:()=>u});var r=t(74848),a=t(96540),l=t(56347),s=t(99989),o=t(96629),i=t(80618),c=t(41367);function u(e){return a.Children.toArray(e).filter(e=>"\n"!==e)}function d({value:e,tabValues:n}){return n.some(n=>n.value===e)}function p(e){let n,{defaultValue:t,queryString:r=!1,groupId:u}=e,p=function(e){let{values:n,children:t}=e;return(0,a.useMemo)(()=>{let e=n??a.Children.toArray(t).flatMap(e=>{if(!e)return[];if((0,a.isValidElement)(e)&&function(e){let{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return[e];
1let n="string"==typeof e.type?e.type:e.type.name;throw Error(`Docusaurus error: Bad <Tabs> child <${n}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.
2If you do not want to pass on a "value" prop to the direct children of <Tabs>, you can also pass an explicit <Tabs values={...}> prop.`)}).map(({props:{value:e,label:n,attributes:t,default:r}})=>({value:e,label:n,attributes:t,default:r})),r=(0,i.XI)(e,(e,n)=>e.value===n.value);if(r.length>0)throw Error(`Docusaurus error: Duplicate values "${r.map(e=>`'${e.value}'`).join(", ")}" found in <Tabs>. Every value needs to be unique.`);return e},[n,t])}(e),[f,h]=(0,a.useState)(()=>(function({defaultValue:e,tabValues:n}){if(0===n.length)throw Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!d({value:e,tabValues:n}))throw Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${n.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}let t=n.find(e=>e.default)??n[0];if(!t)throw Error("Unexpected error: 0 tabValues");return t.value})({defaultValue:t,tabValues:p})),[y,m]=function({queryString:e=!1,groupId:n}){let t=(0,l.W6)(),r=function({queryString:e=!1,groupId:n}){if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!n)throw Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return n??null}({queryString:e,groupId:n});return[(0,o.aZ)(r),(0,a.useCallback)(e=>{if(!r)return;let n=new URLSearchParams(t.location.search);n.set(r,e),t.replace({...t.location,search:n.toString()})},[r,t])]}({queryString:r,groupId:u}),[x,g]=function({groupId:e}){let n=e?`docusaurus.tab.${e}`:null,[t,r]=(0,c.Dv)(n);return[t,(0,a.useCallback)(e=>{n&&r.set(e)},[n,r])]}({groupId:u}),j=d({value:n=y??x,tabValues:p})?n:null;return(0,s.A)(()=>{j&&h(j)},[j]),{selectedValue:f,selectValue:(0,a.useCallback)(e=>{if(!d({value:e,tabValues:p}))throw Error(`Can't select invalid tab value=${e}`);h(e),m(e),g(e)},[m,g,p]),tabValues:p,lazy:e.lazy??!1,block:e.block??!1}}let f=(0,a.createContext)(null);function h(){let e=a.useContext(f);if(!e)throw Error("useTabsContext() must be used within a Tabs component");return e}function y(e){return(0,r.jsx)(f.Provider,{value:e.value,children:e.children})}},50580(e,n,t){t.d(n,{A:()=>d});var r=t(74848);t(96540);var a=t(34164),l=t(88287),s=t(57663),o=t(28584);function i({className:e}){let{selectedValue:n,selectValue:t,tabValues:l,block:c}=(0,s.uc)(),u=[],{blockElementScrollPositionUntilNextRender:d}=(0,o.a_)(),p=e=>{let r=e.currentTarget,a=l[u.indexOf(r)].value;a!==n&&(d(r),t(a))},f=e=>{let n=null;switch(e.key){case"Enter":p(e);break;case"ArrowRight":{let t=u.indexOf(e.currentTarget)+1;n=u[t]??u[0];break}case"ArrowLeft":{let t=u.indexOf(e.currentTarget)-1;n=u[t]??u[u.length-1]}}n?.focus()};return(0,r.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,a.A)("tabs",{"tabs--block":c},e),children:l.map(({value:e,label:t,attributes:l})=>(0,r.jsx)("li",{role:"tab",tabIndex:n===e?0:-1,"aria-selected":n===e,ref:e=>{u.push(e)},onKeyDown:f,onClick:p,...l,className:(0,a.A)("tabs__item","tabItem_hGfb",l?.className,{"tabs__item--active":n===e}),children:t??e},e))})}function c({children:e}){return(0,r.jsx)("div",{className:"margin-top--md",children:e})}function u({className:e,children:n}){return(0,r.jsxs)("div",{className:(0,a.A)(l.G.tabs.container,"tabs-container","tabList_TRJ7"),children:[(0,r.jsx)(i,{className:e}),(0,r.jsx)(c,{children:n})]})}function d(e){let n=(0,s.OC)(e);return(0,r.jsx)(s.O_,{value:n,children:(0,r.jsx)(u,{className:e.className,children:(0,s.vT)(e.children)})})}},28453(e,n,t){t.d(n,{R:()=>s,x:()=>o});var r=t(96540);let a={},l=r.createContext(a);function s(e){let n=r.useContext(l);return r.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:s(e.components),r.createElement(l.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.