Skip to main content
All posts
Guide

Deploy to Production

How to build and deploy your app to Cloudflare Workers.

Once your app is ready, you can deploy it with a single command.

Build

Create an optimized production build:

pnpm build

CF writes Build Output to .cloudflare/output/v0/. The default Worker bundle and static assets live under workers/default/bundle/ and workers/default/assets/ inside that directory. The build uses the Cloudflare Vite plugin, so the bundle is ready for Workers.

Deploy to Cloudflare

If you use the included CF setup:

pnpm run deploy

This runs cf deploy, which builds and deploys the Worker. Configure your account and bindings in cloudflare.config.ts, and set any required environment variables or secrets with pnpm sync-worker-secrets.

For a new Worker, include its initial secrets in the deployment:

pnpm run deploy --secrets-file .env.production

Keep this file out of Git. Later, use pnpm sync-worker-secrets to update secrets on the existing Worker.

Check the Worker bundle size

Cloudflare Workers Free and Paid plans both allow an uncompressed Worker bundle of up to 64 MiB. There is no compressed-size limit; the gzip size in CF's output is only provided for reference.

Check the bundle before deploying:

pnpm exec cf deploy --dry-run

The Total Upload value is the uncompressed size that counts toward the 64 MiB limit. See Cloudflare's Worker size limits for the current details.

img

Good luck with your launch.