From 9aa38723e962ea10dcd3f0aca325e1cd44afbc65 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Sat, 24 Jan 2026 16:16:52 +0000 Subject: [PATCH 1/2] Add documentation for new `migrate` Cloudflare CLI command --- pages/cloudflare/cli.mdx | 21 ++++++++++++++++++++- pages/cloudflare/get-started.mdx | 10 ++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/pages/cloudflare/cli.mdx b/pages/cloudflare/cli.mdx index 61440ae..0fa06d1 100644 --- a/pages/cloudflare/cli.mdx +++ b/pages/cloudflare/cli.mdx @@ -8,7 +8,7 @@ The Cloudflare adapter provides a `opennextjs-cloudflare` CLI to develop, build, `opennextjs-cloudflare` support multiple commands, invoked via `opennextjs-cloudflare `. -The currently supported commands are `build`, `populateCache`, `preview`, `deploy`, and `upload`. +The currently supported commands are `build`, `populateCache`, `preview`, `deploy`, `upload`, and `migrate`. You can list the commands by invoking `pnpm opennextjs-cloudflare` and get help with a given command by invoking `pnpm opennextjs-cloudflare --help`. @@ -47,3 +47,22 @@ It starts by populating the remote cache and then deploys your application to Cl ### `upload` command It starts by populating the remote cache and then uploads a version of your application to Cloudflare (via `wrangler upload`). Note that the application will not automatically be served on uploads. See [Gradual deployments](https://developers.cloudflare.com/workers/configuration/versions-and-deployments/gradual-deployments/) to learn more about how to serve an uploaded version. + +### `migrate` command + +Converts a standard Next.js project into an OpenNext-compatible one. This command automates the setup steps described in the [Get Started guide](/cloudflare/get-started#existing-nextjs-apps), including: + +- Installing required dependencies (`@opennextjs/cloudflare` and `wrangler`) +- Creating a `wrangler.jsonc` configuration file +- Creating an `open-next.config.ts` file +- Adding a `.dev.vars` file +- Updating the `package.json` scripts +- Adding static asset caching headers (`public/_headers`) +- Adding `.open-next` to `.gitignore` +- Setting up local development with `initOpenNextCloudflareForDev()` in your Next.js config + +Run the command in your existing Next.js project: + +```sh +npx @opennextjs/cloudflare migrate +``` diff --git a/pages/cloudflare/get-started.mdx b/pages/cloudflare/get-started.mdx index f5cd1ba..e125532 100644 --- a/pages/cloudflare/get-started.mdx +++ b/pages/cloudflare/get-started.mdx @@ -12,6 +12,16 @@ npm create cloudflare@latest -- my-next-app --framework=next --platform=workers #### Existing Next.js apps +The easiest way to convert an existing Next.js app is to use the `migrate` command: + +```sh +npx @opennextjs/cloudflare migrate +``` + +This command automates all the setup steps below. See the [CLI documentation](/cloudflare/cli#migrate-command) for more details. + +Alternatively, you can follow the manual steps below. + ##### 1. Install @opennextjs/cloudflare First, install [@opennextjs/cloudflare](https://www.npmjs.com/package/@opennextjs/cloudflare): From 9d579a03146adcb8a3ccd9ac4ee0076231ccdf4b Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Tue, 24 Feb 2026 12:57:46 +0000 Subject: [PATCH 2/2] update docs to mention R2 bucket creation --- pages/cloudflare/cli.mdx | 8 ++++++++ pages/cloudflare/get-started.mdx | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pages/cloudflare/cli.mdx b/pages/cloudflare/cli.mdx index 0fa06d1..5761883 100644 --- a/pages/cloudflare/cli.mdx +++ b/pages/cloudflare/cli.mdx @@ -61,6 +61,14 @@ Converts a standard Next.js project into an OpenNext-compatible one. This comman - Adding `.open-next` to `.gitignore` - Setting up local development with `initOpenNextCloudflareForDev()` in your Next.js config +Additionally, the command creates an R2 bucket and configures it for caching. + + + The R2 bucket for caching is only created if R2 is enabled on your Cloudflare account. If R2 is not enabled, + no caching setup is performed by the migrate command. See the [Caching docs](/cloudflare/caching) for + information on manually configuring caching. + + Run the command in your existing Next.js project: ```sh diff --git a/pages/cloudflare/get-started.mdx b/pages/cloudflare/get-started.mdx index e125532..82b5369 100644 --- a/pages/cloudflare/get-started.mdx +++ b/pages/cloudflare/get-started.mdx @@ -18,7 +18,7 @@ The easiest way to convert an existing Next.js app is to use the `migrate` comma npx @opennextjs/cloudflare migrate ``` -This command automates all the setup steps below. See the [CLI documentation](/cloudflare/cli#migrate-command) for more details. +This command automates all the setup steps below. If R2 is enabled on your account, it also creates an R2 bucket for caching. See the [CLI documentation](/cloudflare/cli#migrate-command) for more details. Alternatively, you can follow the manual steps below.