Cloudflare
The @opennextjs/cloudflare
(opens in a new tab) adapter lets you deploy Next.js apps to Cloudflare Workers (opens in a new tab) using the Node.js "runtime" from Next.js (opens in a new tab).
@opennextjs/cloudflare
(opens in a new tab) is pre 1.0, and still in active development. You should try it, report bugs (opens in a new tab), share feedback (opens in a new tab), and contribute code to help make running Next.js apps on Cloudflare easier. We don't quite yet recommend using it for mission-critical production apps.
You can also use @cloudflare/next-on-pages
(opens in a new tab) to deploy Next.js apps to Cloudflare Pages. You can review the differences in supported Next.js features below and by reviewing the docs for @cloudflare/next-on-pages
(opens in a new tab), and understand the differences between Workers and Pages here (opens in a new tab).
Get Started
New apps
To create a new Next.js app, pre-configured to run on Cloudflare using @opennextjs/cloudflare, run:
npm create cloudflare@latest -- my-next-app --framework=next --experimental
Existing Next.js apps
Follow the guide here to use @opennextjs/cloudflare (opens in a new tab) with an existing Next.js app.
Supported Next.js runtimes
Next.js has two "runtimes" (opens in a new tab) — "Edge" and "Node.js". When you use @opennextjs/cloudflare
, your app can use the Node.js runtime, which is more fully featured, and allows you to use the Node.js APIs (opens in a new tab) that are provided by the Cloudflare Workers runtime.
This is an important difference from @cloudflare/next-on-pages
, which only supports the "Edge" runtime. The Edge Runtime code in Next.js intentionally constrains which APIs from Node.js can be used (opens in a new tab), and the "Edge" runtime does not support all Next.js features.
Supported Next.js versions
@opennextjs/cloudflare
is pre 1.0, and still in active development. We intend to support all minor and patch version of Next.js 13 and 14, as well as Next.js 15 when it is released. (currently a release candidate)
To help improve compatibility, we encourage you to report bugs (opens in a new tab) and contribute code!
Supported Next.js features
- App Router (opens in a new tab)
- Route Handlers (opens in a new tab)
- Dynamic routes (opens in a new tab)
- Static Site Generation (SSG) (opens in a new tab)
- Server-Side Rendering (SSR) (opens in a new tab)
Not Yet Supported Next.js features
The following Next.js features are not yet supported — but we welcome both contributions and feedback! Tell us what you'd like to see, or what you'd like to add support for:
- Pages Router (opens in a new tab) (you should use the App Router instead, which was introduced in Next.js 13)
- Incremental Static Regeneration (ISR) (opens in a new tab)
- Partial Prerendering (PPR) (opens in a new tab)
- Middleware (opens in a new tab)
- Image optimization (opens in a new tab) (you can integrate Cloudflare Images with Next.js by following this guide (opens in a new tab))
- Experimental streaming support (opens in a new tab)
How @opennextjs/cloudflare Works
The OpenNext Cloudflare adapter works by taking the Next.js build output and transforming it, so that it can run in Cloudflare Workers.
When you add @opennextjs/cloudflare (opens in a new tab) as a dependency to your Next.js app, and then run npx cloudflare
the adapter first builds your app by running next build
, and then transforms the build output to a format that you can run locally using Wrangler (opens in a new tab), and deploy to Cloudflare.
You can view the code for @opennextjs/cloudflare here (opens in a new tab) to understand what it does under the hood.