CloudflareDeployer
The CloudflareDeployer class handles deployment of standalone Mastra applications to Cloudflare Workers. It manages configuration, deployment, and extends the base Deployer class with Cloudflare specific functionality.
Usage exampleDirect link to Usage example
src/mastra/index.ts
import { Mastra } from "@mastra/core";
import { CloudflareDeployer } from "@mastra/deployer-cloudflare";
export const mastra = new Mastra({
deployer: new CloudflareDeployer({
name: "hello-mastra",
routes: [
{
pattern: "example.com/*",
zone_name: "example.com",
custom_domain: true
}
],
vars: {
NODE_ENV: "production",
API_KEY: "<api-key>"
},
d1_databases: [
{
binding: "DB",
database_name: "my-database",
database_id: "d1-database-id",
preview_database_id: "your-preview-database-id"
}
],
kv_namespaces: [
{
binding: "CACHE",
id: "kv-namespace-id"
}
]
})
});
Constructor optionsDirect link to Constructor options
The CloudflareDeployer constructor accepts the same configuration options as wrangler.json. See the Wrangler configuration documentation for all available options.
Migrating from earlier versionsDirect link to Migrating from earlier versions
The following fields are deprecated and should be replaced with their standard wrangler.json equivalents:
| Deprecated | Use instead |
|---|---|
projectName | name |
d1Databases | d1_databases |
kvNamespaces | kv_namespaces |
workerNamespace | (removed, no longer used) |