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
src/mastra/index.ts
import { Mastra } from "@mastra/core/mastra";
import { CloudflareDeployer } from "@mastra/deployer-cloudflare";
export const mastra = new Mastra({
  // ...
  deployer: new CloudflareDeployer({
    projectName: "hello-mastra",
    routes: [
      {
        pattern: "example.com/*",
        zone_name: "example.com",
        custom_domain: true
      }
    ],
    workerNamespace: "my-namespace",
    env: {
      NODE_ENV: "production",
      API_KEY: "<api-key>"
    },
    d1Databases: [
      {
        binding: "DB",
        database_name: "my-database",
        database_id: "d1-database-id",
        preview_database_id: "your-preview-database-id"
      }
    ],
    kvNamespaces: [
      {
        binding: "CACHE",
        id: "kv-namespace-id"
      }
    ]
});
Parameters
projectName?:
string
= 'mastra'
Name of your worker project.
routes?:
CFRoute[]
Array of route configurations for your worker. Each route requires: pattern (string), zone_name (string), custom_domain (boolean, optional).
workerNamespace?:
string
Namespace for your worker.
env?:
Record<string, any>
Environment variables to be included in the worker configuration.
d1Databases?:
D1DatabaseBinding[]
Array of D1 database bindings. Each binding requires: binding (string), database_name (string), database_id (string), preview_database_id (string, optional).
kvNamespaces?:
KVNamespaceBinding[]
Array of KV namespace bindings. Each binding requires: binding (string), id (string).