Cloudflare
Overview

Cloudflare

The @opennextjs/cloudflare (opens in a new tab) adapter lets you deploy Next.js apps to Cloudflare Workers (opens in a new tab) and Cloudflare Pages (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 between @opennextjs/cloudflare and @cloudflare/next-on-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:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/11040899018/npm-package-create-cloudflare-6830 --no-auto-update --experimental --framework next
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 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

1 "Manual" revalidation is not supported (i.e. revalidateTag() (opens in a new tab) or revalidatePath() (opens in a new tab))

Not Yet Supported Next.js features

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.