Socket
Book a DemoInstallSign in
Socket

@caleblawson/deployer-cloudflare

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@caleblawson/deployer-cloudflare

A Cloudflare Workers deployer for Mastra applications.

latest
npmnpm
Version
0.10.7-alpha.0
Version published
Maintainers
1
Created
Source

@mastra/deployer-cloudflare

A Cloudflare Workers deployer for Mastra applications.

Features

  • Deploy Mastra applications to Cloudflare Workers
  • Configure custom domains and routes
  • Support for worker namespaces
  • Automatic environment variable configuration

Installation

pnpm add @mastra/deployer-cloudflare

Usage

The Cloudflare deployer is used as part of the Mastra framework:

import { Mastra } from '@mastra/core';
import { CloudflareDeployer } from '@mastra/deployer-cloudflare';

const deployer = new CloudflareDeployer({
  scope: 'your-account-id',
  projectName: 'your-project-name',
  routes: [
    {
      pattern: 'example.com/*',
      zone_name: 'example.com',
      custom_domain: true,
    },
  ],
  workerNamespace: 'your-namespace',
  auth: {
    apiToken: 'your-api-token',
    apiEmail: 'your-email',
  },
});

const mastra = new Mastra({
  deployer,
  // ... other Mastra configuration options
});

Configuration

Constructor Options

  • scope (required): Your Cloudflare account ID
  • projectName: Name of your worker project
  • routes: Array of route configurations for your worker
    • pattern: URL pattern to match
    • zone_name: Domain zone name
    • custom_domain: Whether to use a custom domain
  • workerNamespace: Namespace for your worker
  • auth: Cloudflare authentication details
    • apiToken: Your Cloudflare API token
    • apiEmail: Your Cloudflare account email

Environment Variables

The deployer will automatically load environment variables from:

  • .env files in your project
  • Environment variables passed through the Mastra configuration

Routes

Routes can be configured to direct traffic to your worker based on URL patterns and domains:

const routes = [
  {
    pattern: 'api.example.com/*',
    zone_name: 'example.com',
    custom_domain: true,
  },
  {
    pattern: 'example.com/api/*',
    zone_name: 'example.com',
  },
];

Each route requires:

  • pattern: URL pattern to match
  • zone_name: Domain zone name
  • custom_domain: (optional) Set to true to use a custom domain

Requirements

  • Cloudflare account with Workers enabled
  • API token with appropriate permissions
  • Domain(s) configured in Cloudflare (for custom domains)

FAQs

Package last updated on 20 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts