
If you want to deploy a Next.js app on Cloudflare Workers, this is one of the simplest ways to do it.
You will use:
This setup is beginner-friendly and works well for modern Next.js projects that use the standard Node.js runtime.
Before you start, make sure you have:
Login command:
npx wrangler loginIf Wrangler is not installed yet, run:
npm install -D wrangler@latestCheck it:
npx wrangler --versionFor modern OpenNext deployments, keep Wrangler updated. Current OpenNext docs require a recent Wrangler version for Next.js on Workers.
For an existing Next.js project, the easiest method is:
npx @opennextjs/cloudflare migrateThis command prepares the project for Cloudflare and typically sets up:
wrangler.jsoncopen-next.config.tsIf your project is older, review the generated files before deploying so you understand what changed.
Run:
npm run buildIf your build fails, fix those errors first. Do not deploy before the Next.js production build works cleanly.
Test the Cloudflare version locally:
npm run previewThis is useful because it runs your app closer to the real Cloudflare Workers runtime, which helps you catch deployment-specific issues earlier.
Now deploy your Next.js app:
npm run deployIf your project uses Wrangler directly, this can also work:
npx wrangler deployAfter deployment, Cloudflare gives you a workers.dev URL.
Example:
https://your-app-name.your-account.workers.devOpenNext for Cloudflare is designed around the Node.js runtime for Next.js. If you have routes that explicitly use the Edge runtime, review them before deploying.
If your project uses caching, images, or extra bindings, Cloudflare may also create or expect:
Much of this can be handled automatically by the OpenNext migration, but it is still worth checking your generated wrangler.jsonc.
When OpenNext generates a wrangler.jsonc, avoid changing core output fields unless you know why. That config is what lets your built Next.js app run correctly on Workers.
npx wrangler login
npx @opennextjs/cloudflare migrate
npm run build
npm run preview
npm run deployTo connect Cloudflare to a Next.js project and deploy Next.js to Cloudflare Workers, you mainly need Wrangler, the OpenNext Cloudflare adapter, and a clean production build.
If you are a beginner, follow this order:
That is the simplest way to deploy Next.js to Cloudflare Workers without getting lost in setup.