We first announced the Cloudflare adapter for OpenNext at Builder Day 2024. It transforms Next.js applications to enable them to run on Cloudflare’s infrastructure.
Over the seven months since that September announcement, we have been working hard to improve the adapter. It is now more tightly integrated with OpenNext to enable supporting many more Next.js features. We kept improving the Node.js compatibility of Workers and unenv was also improved to polyfill the Node.js features not yet implemented by the runtime.
With all of this work, we are proud to announce the 1.0.0-beta release of @opennextjs/cloudflare. Using the Cloudflare adapter is now the preferred way to deploy Next applications to the Cloudflare platform, instead of Next on Pages.
Read on to learn what is possible today, and about our plans for the coming months.
OpenNext
OpenNext is a build tool designed to transform Next.js applications into packages optimized for deployment across various platforms. Initially created for serverless environments on AWS Lambda, OpenNext has expanded its capabilities to support a wider range of environments, including Cloudflare Workers and traditional Node.js servers.
By integrating with the OpenNext codebase, the Cloudflare adapter is now able to support many more features than its original version. We are also leveraging the end-to-end (e2e) test suite of OpenNext to validate the implementation of these features. Being part of OpenNext allows us to support future Next.js features shortly after they are released. We intend to support the latest minor version of Next.js 14 and all the minor versions of Next.js 15.
Features
Most of the Next.js 15 features are supported in @opennextjs/cloudflare
. You can find an exhaustive list on the OpenNext website, but here are a few highlights:
The Cloudflare adapter provides a cache handler for Next.js, optimizing the management of ISR/SSG and the data cache to speed up your apps. | |
PPR immediately sends the pre-rendered HTML and begins streaming from the server in parallel. | |
Middleware allows modifying the response by rewriting, redirecting, or modifying the request and response headers, or responding directly before the request hits the app. | |
Both the new App router and Pages routers are supported. | |
The adapter easily integrates with Cloudflare Images to deliver optimized images. |
We are working on adding more features:
Microsoft Windows is not yet fully supported by the adapter. We plan to fully support Windows for development in the 1.0 release.
The adapter currently only supports the Node runtime of Next.js. You can opt-out of the Edge runtime by removing
export const runtime = "edge"
from your application. We plan to add support for the edge runtime in the next major release. Note that applications deployed to Cloudflare Workers run close to the user, whatever the Next.js runtime used, giving similar performance.Composable caching (
use cache
) should also be supported in the next major release. It is a canary feature of Next.js that is still in development. It will be supported in OpenNext once it stabilizes.
Evolution in the ecosystem
While the adapter has vastly improved over the last several months, we should also mention the updates to the ecosystem that are enabling more applications to be supported.
NodeJS compatibility for Workers is becoming more comprehensive with the crypto
, dns
, timers
, tls
, and net
NodeJS modules now being natively implemented by the Workers runtime. The remaining modules that are not yet implemented are supported through unenv.
The Worker size limit was bumped from 1 MiB to 3 MiB on free plans and from 10 MiB to 15 MiB for paid plans.
1.0 and the road ahead
With the release of 1.0-beta, we expect most Next.js 14 and 15 applications to be able to run seamlessly on Cloudflare.
We have already tackled a lot of the issues reported on GitHub by early adopters, and once the adapter stabilizes, we will release the 1.0 version.
After that, we are planning a v2 release with a focus on:
Reducing the bundle size.
Improving the application performance. The reduced bundle size and more work on the caching layer will make applications faster.
Allowing users to deploy to multiple Workers.
Deploy your first application to Workers
Developing and deploying a Next.js app on Workers is pretty simple, and you can do it today by following these steps:
Start by creating your application from a template:
npm create cloudflare@latest -- my-next-app --framework=next
--platform=workers
You can then iterate on your application using the Next.js dev server by running npm run dev
.
Once you are happy with your application in the development server, you can run the application on Workers locally by executing npm run preview
, or deploy the application with npm run deploy
.
You can find more details in the documentation, on both the Cloudflare site and the OpenNext site.
We want your feedback! Report issues and contribute code at opennextjs/opennextjs-cloudflare on Github, and join the discussion on the OpenNext Discord.