Deploying Next.js to Cloudflare with OpenNext

The setup I used to run a Next.js portfolio on Cloudflare's edge, and the pitfalls to avoid.
My previous portfolio ran on Cloudflare using the OpenNext adapter. Cloudflare's network is fast and affordable, and OpenNext lets most Next.js features run there.
Install the adapter
npm install -D @opennextjs/cloudflare wrangler
# package.json
"preview": "opennextjs-cloudflare build && opennextjs-cloudflare preview",
"deploy": "opennextjs-cloudflare build && opennextjs-cloudflare deploy"Configure Wrangler
wrangler.jsonc names the Worker, sets the compatibility date and enables Node.js compatibility flags. Keep secrets out of this file and set them with wrangler secret put or in the dashboard.
Preview locally before deploying
The preview script runs your build on the Workers runtime locally. Anything that depends on Node-only APIs shows up here instead of in production.
Common pitfalls
- Large dependencies can push the Worker over its size limit; check bundle size.
- Some Node.js APIs are unavailable; prefer web-standard APIs like fetch and crypto.subtle.
- Set up caching for ISR and images as described in the adapter docs.
Automate it
A GitHub Actions workflow that runs the deploy script on pushes to main means production always matches the main branch.









