Prerequisites
- Node.js 20+ and npm.
- A Cloudflare account with Workers and D1.
- wrangler CLI installed and authenticated.
- A domain for access (optional).
Deploy to Cloudflare Workers
The Next.js app is adapted by OpenNext and deployed to Workers.
- Install dependencies and verify a local build.
- Generate the Workers bundle with OpenNext.
- Publish with wrangler.
- Bind a custom domain after the first deploy.
npx --yes opennextjs-cloudflare build
npx --yes wrangler deployEnvironment variables
Set the following variables in the wrangler config or dashboard.
| Variable | Description |
|---|---|
| JWT_SECRET | Signing secret for auth tokens — use a strong random value. |
| ADMIN_EMAIL | Bootstrap admin email. |
| ADMIN_PASSWORD | Bootstrap admin password; change it after first login. |
| LLM_BASE_URL | Default LLM endpoint (optional). |
| DB | D1 database binding name. |
Init & migrate
On first deploy, create the D1 database and run the schema.
wrangler d1 create ezp-db
wrangler d1 execute ezp-db --file=./schema.sql
npx --yes wrangler deployTip: after schema changes, re-run the schema to migrate; back up production data first.
Release flow
- Run type-check and unit tests locally.
- Build and preview locally to confirm pages render.
- Deploy to Cloudflare and verify in the browser.
Verify critical paths in a preview environment before release.
