Skip to content

OpenNext adapter

Last updated View as MarkdownAgent setup

Use this guide to maintain an existing OpenNext application. Migrate to vinext when compatibility allows.

OpenNext adapts the output of next build so it can run on different platforms, including Cloudflare Workers.

Supported features

Most Next.js features are supported by the Cloudflare OpenNext adapter:

Feature Cloudflare OpenNext adapter Notes
App Router Supported
Pages Router Supported
Route Handlers Supported
React Server Components Supported
Static Site Generation (SSG) Supported
Server-Side Rendering (SSR) Supported
Incremental Static Regeneration (ISR) Supported
Server Actions Supported
Response streaming Supported
Asynchronous work with next/after Supported
Middleware Supported
Image optimization Supported Supported through Cloudflare Images.
Partial Prerendering (PPR) Supported PPR is experimental in Next.js.
Composable Caching ("use cache") Supported Composable Caching is experimental in Next.js.
Node.js in Middleware Not yet supported Node.js middleware introduced in Next.js 15.2 is not yet supported.

For detailed OpenNext documentation, refer to OpenNext for Cloudflare.

Configure OpenNext manually

Wrangler automatic configuration uses vinext for Next.js projects. To use OpenNext, configure the adapter manually.

  1. Install the OpenNext Cloudflare adapter.

    npm i @opennextjs/cloudflare@latest
  2. Install Wrangler.

    npm i -D wrangler@latest
  3. Add a Wrangler configuration file.

    In your project root, create a Wrangler configuration file with the following content:

    {
      "$schema": "./node_modules/wrangler/config-schema.json",
      "name": "my-app",
      "main": ".open-next/worker.js",
      // Set this to today's date
      "compatibility_date": "2026-08-25",
      "compatibility_flags": [
        "nodejs_compat"
      ],
      "assets": {
        "directory": ".open-next/assets",
        "binding": "ASSETS"
      },
      "observability": {
        "enabled": true
      }
    }
    name = "my-app"
    main = ".open-next/worker.js"
    # Set this to today's date
    compatibility_date = "2026-08-25"
    compatibility_flags = ["nodejs_compat"]
    
    [assets]
    directory = ".open-next/assets"
    binding = "ASSETS"
    
    [observability]
    enabled = true
  4. Add an OpenNext configuration file.

    In your project root, create open-next.config.ts:

    import { defineCloudflareConfig } from "@opennextjs/cloudflare";
    
    export default defineCloudflareConfig();

    Use this file to configure OpenNext features such as caching. For more information, refer to OpenNext caching.

  5. Update package.json.

    Add scripts for previewing, deploying, and generating Cloudflare types:

    {
      "scripts": {
        "preview": "opennextjs-cloudflare build && opennextjs-cloudflare preview",
        "deploy": "opennextjs-cloudflare build && opennextjs-cloudflare deploy",
        "cf-typegen": "wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts"
      }
    }

    Script usage

    • preview: Builds your app and serves it locally in the Workers runtime.
    • deploy: Builds your app and deploys it to Cloudflare Workers.
    • cf-typegen: Generates cloudflare-env.d.ts with Cloudflare binding types.
  6. Develop locally.

    Start the Next.js development server.

    npm run dev
  7. Preview with OpenNext.

    Preview your application in the Workers runtime.

    npm run preview
  8. Deploy your project.

    Deploy your project to Cloudflare Workers.

    npm run deploy

Was this helpful?