Skip to main content
Mastra 1.0 is available 🎉 Read announcement

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 example
Direct 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 options
Direct 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 versions
Direct link to Migrating from earlier versions

The following fields are deprecated and should be replaced with their standard wrangler.json equivalents:

DeprecatedUse instead
projectNamename
d1Databasesd1_databases
kvNamespaceskv_namespaces
workerNamespace(removed, no longer used)
On this page