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) 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 should 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 versions of Next.js 14 and 15.

To help improve compatibility, we encourage you to report bugs (opens in a new tab) and contribute code!

Supported Next.js features

Some Next.js features are not yet supported are not fully tested. We will update the list as we progress towards releasing 1.0.

We welcome both contributions and feedback!

Windows support

OpenNext can be used on Windows systems but Windows full support is not guaranteed because:

  • historically the Next.js tooling itself has had Windows support issues (and OpenNext is built on these tools)
  • the OpenNext team has limited capacity and fully supporting Windows (given the point above) has been determined to be a lower priority, thus the effort and testing on Windows is limited

Given the above, you can develop your application under Windows at your own risk. If you don't have an alternative we recommend either:

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 opennextjs-cloudflare the adapter first builds your app by running the build script in your package.json, 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.