---
title: "CloudflareDeployer | Deployment"
description: "Learn how to deploy a Mastra application to Cloudflare using the Mastra CloudflareDeployer"
---

# CloudflareDeployer

The `CloudflareDeployer` class handles deployment of standalone Mastra applications to Cloudflare Workers. It manages configuration, deployment, and extends the base [Deployer](/reference/v1/deployer/) class with Cloudflare specific functionality.

:::warning
Cloudflare Workers do not support filesystem access. Remove any usage of [LibSQLStore](/reference/v1/storage/libsql) with file URLs from your Mastra configuration. Use in-memory storage (`:memory:`) or external storage providers like Turso, PostgreSQL, or Upstash.
:::

## Installation

```bash
npm install @mastra/deployer-cloudflare@beta
```

## Usage example

```typescript title="src/mastra/index.ts"
import { Mastra } from "@mastra/core";
import { CloudflareDeployer } from "@mastra/deployer-cloudflare";

export const mastra = new Mastra({
  deployer: new CloudflareDeployer({
    projectName: "hello-mastra",
    env: {
      NODE_ENV: "production",
    },
  }),
});
```

> See the [CloudflareDeployer](/reference/v1/deployer/cloudflare) API reference for all available configuration options.

## Manual deployment

Manual deployments are also possible using the [Cloudflare Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/). With the Wrangler CLI installed run the following from your project root to deploy your application.

With the Wrangler CLI installed, login and authenticate with your Cloudflare logins:

```bash
npx wrangler login
```

Run the following to build and deploy your application to Cloudflare

```bash
npm run build && wrangler deploy --config .mastra/output/wrangler.json
```

> You can also run `wrangler dev --config .mastra/output/wrangler.json` from your project root to test your Mastra application locally.

## Build output

The build output for Mastra applications using the `CloudflareDeployer` includes all agents, tools, and workflows in your project, along with Mastra specific files required to run your application on Cloudflare.

```
.mastra/
└── output/
    ├── index.mjs
    └── wrangler.json
package.json
```

The `CloudflareDeployer` automatically generates a `wrangler.json` configuration file in `.mastra/output` with the following settings:

```json
{
  "name": "hello-mastra",
  "main": "./index.mjs",
  "compatibility_date": "2025-04-01",
  "compatibility_flags": [
    "nodejs_compat",
    "nodejs_compat_populate_process_env"
  ],
  "observability": { "logs": { "enabled": true } },
  "vars": {
    "OPENAI_API_KEY": "...",
    "CLOUDFLARE_API_TOKEN": "..."
  }
}
```

## Next steps

- [Mastra Client SDK](/reference/v1/client-js/mastra-client)
