---
title: "Deploy to Cloudflare"
description: "Create the D1, R2, and Queue resources, set secrets, and deploy the EdgeCart Workers."
---

> Documentation Index
> Fetch the complete documentation index at: https://edgecart.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy to Cloudflare

This guide deploys EdgeCart to your own Cloudflare account. A static docs site
does not need this; this is for a self-hosted store.

## Before you start

- A Cloudflare account with Wrangler authenticated:
  `pnpm --filter edgecart exec wrangler login`.
- A Workers Paid plan if you want plugin Dynamic Workers.
- A domain you can attach to the main Worker.

## 1. Create the D1 database

```sh
pnpm --filter edgecart exec wrangler d1 create edgecart
```

Copy the returned `database_id` into:
- `apps/edgecart/wrangler.jsonc`
- `apps/edgecart-plugins/wrangler.jsonc`
- `apps/edgecart/workers/outbox/wrangler.jsonc`

`pnpm bootstrap` can create the database and patch the main config for you. The
plugin and outbox configs still need the same ID.

Apply the schema to the remote database:

```sh
pnpm db:migrate:remote
```

## 2. Create R2 buckets

```sh
pnpm --filter edgecart exec wrangler r2 bucket create edgecart-uploads
pnpm --filter edgecart exec wrangler r2 bucket create edgecart-plugin-bundles
pnpm --filter edgecart exec wrangler r2 bucket create edgecart-plugin-assets
```

The main app uses `edgecart-uploads`; the plugin kernel uses
`edgecart-plugin-bundles`; the assets Worker uses `edgecart-plugin-assets`.

## 3. Create the queues

```sh
pnpm --filter edgecart exec wrangler queues create edgecart-outbox
pnpm --filter edgecart exec wrangler queues create edgecart-outbox-dlq
```

The outbox consumer retries five times before sending a message to the DLQ.

## 4. Set secrets

Set the main app's secrets from `apps/edgecart`:

```sh
cd apps/edgecart
pnpm exec wrangler secret put BETTER_AUTH_SECRET
pnpm exec wrangler secret put TRUSTED_ORIGINS
pnpm exec wrangler secret put STRIPE_SECRET_KEY
pnpm exec wrangler secret put STRIPE_PUBLISHABLE_KEY
pnpm exec wrangler secret put STRIPE_WEBHOOK_SECRET
pnpm exec wrangler secret put PLUGIN_ASSETS_ORIGIN
pnpm exec wrangler secret put PLUGIN_ENCRYPTION_KEY
pnpm exec wrangler secret put PLATFORM_ADMIN_EMAILS
```

Add SMTP values and `EMAIL_FROM` for the outbox Worker. See
[Configuration & secrets](https://edgecart.dev/developers/configuration) for the full list.

## 5. Deploy the Workers

```sh
# Main app (build + wrangler deploy)
pnpm deploy

# Plugin kernel
pnpm --filter @edgecart/plugin-kernel deploy

# Plugin assets
pnpm --filter @edgecart/plugin-assets deploy

# Outbox worker
pnpm --filter edgecart outbox:deploy
```

Deploy the plugin kernel before plugins are installed. The outbox Worker can be
deployed after the main app, but webhooks and order email stay pending until it
runs.

## 6. Attach the domain and verify

1. Attach your domain to the `edgecart` Worker in the Cloudflare dashboard.
2. Update `TRUSTED_ORIGINS` to include the storefront and admin origins.
3. Open `/` and `/admin`; create the first account and claim the store.
4. Add a product, a shipping option, and a tax rate.
5. Send a test webhook and confirm a delivery attempt appears.

## Production checklist

- [ ] D1 `database_id` matches in all three Worker configs.
- [ ] Remote migrations applied.
- [ ] R2 buckets and both queues exist.
- [ ] `BETTER_AUTH_SECRET` is a strong random value.
- [ ] `TRUSTED_ORIGINS` lists only your origins.
- [ ] Stripe keys are from the same account; webhook secret is set.
- [ ] Outbox Worker is deployed with email configuration.
- [ ] Plugin kernel and assets Workers are deployed if plugins are used.
- [ ] Workers Paid plan is active for Dynamic Workers.
- [ ] Custom domain is attached and serving.

## Related

- [Configuration & secrets](https://edgecart.dev/developers/configuration)
- [Architecture](https://edgecart.dev/developers/architecture)
- [Current limitations](https://edgecart.dev/reference/limitations)

Source: https://edgecart.dev/developers/deployment/index.mdx
