Skip to main content
Deploy Next.js applications to Cloudflare Workers using the OpenNext Cloudflare adapter.

Installation

Install the required dependencies:

Configuration

Configuration Options

Properties

  • bindings: Cloudflare bindings (KV, R2, D1, etc.)
  • build: Build command override
    • Default: opennextjs-cloudflare build
  • dev: Dev command override
    • Default: next dev
  • entrypoint: Worker entrypoint path
    • Default: .open-next/worker.js
  • assets: Static assets directory
    • Default: .open-next/assets
  • noBundle: Skip bundling (useful for debugging)
    • Default: false

Build Configuration

The Next.js resource automatically:
  • Runs OpenNext Cloudflare build
  • Bundles the worker with minification
  • Sets nodejs_compat compatibility flag
  • Configures environment variables

Custom Build Command

Development Server

Customize the development server configuration:
Start the dev server:

Accessing Bindings

Access Cloudflare bindings in your Next.js app using the platform env:

Compatibility Flags

The Next.js resource automatically sets:
  • nodejs_compat - Node.js compatibility
  • global_fetch_strictly_public - Fetch API compatibility
Add additional flags:

Limitations

  • Not all Next.js features are supported on Cloudflare Workers
  • Consult the OpenNext Cloudflare documentation for current limitations
  • Some Node.js APIs may not be available