Cloudflare Quickstart
readyDeploy an unmodified Next.js 14, 15, or 16 (Turbopack) app to Cloudflare Workers + R2 with automatic resource provisioning and custom domain attachment.
Source reference: cli/internal/serverless/cloudflare*.go, shared/nextcompile/, docs/targets/cloudflare.md
Prerequisites
- A Next.js app with
output: 'standalone'innext.config.mjs. - A Cloudflare account ID and an API token (see the full Cloudflare API Token Permissions guide):
- Account → Workers Scripts: Edit
- Account → Workers R2 Storage: Edit
- Account → Workers KV Storage / D1 / Queues / Hyperdrive: Edit (for any bindings you declare)
- Zone → DNS: Edit & Zone → Zone: Read (for custom domains)
- Zone → Cache Purge: Purge (required for automatic edge cache purge)
[!TIP] Ensure you create a User API Token (
My Profile → API Tokens) rather than an Account API Token to avoid401 Unauthorizederrors during cache purge. See API Token Permissions for step-by-step setup.
1. Export Credentials
export CLOUDFLARE_ACCOUNT_ID="your-account-id"
export CLOUDFLARE_API_TOKEN="your-api-token"
2. Configure nextdeploy.yml
version: "1.0"
target_type: serverless
app:
name: my-edge-app
domain: app.example.com
environment: production
serverless:
provider: cloudflare
cloudflare:
engine: auto # auto selects nextserver for Turbopack & Next.js 16+
compatibility_date: "2026-05-01"
compatibility_flags:
- nodejs_compat
3. Plan & Ship
nextdeploy plan # Preview resources, bindings, and drift
nextdeploy ship # Build, compile worker.mjs (~1.60 MB gzipped), sync R2, deploy, smoke verify
Deployment reports are saved to .nextdeploy/reports/ (gitignored), and live logs can be tailed with nextdeploy logs.