From 9aa38723e962ea10dcd3f0aca325e1cd44afbc65 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Sat, 24 Jan 2026 16:16:52 +0000 Subject: [PATCH] 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):