Skip to content

Commit feb92d1

Browse files
authored
Clarify steps to migrate off @cloudflare/next-on-pages
1 parent 3c692e2 commit feb92d1

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

pages/cloudflare/get-started.mdx

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ id = "<YOUR_NAMESPACE_ID>"
9090

9191
As shown above, the name of the binding that you configure for the KV namespace must be set to `NEXT_CACHE_WORKERS_KV`.
9292

93+
### 5. Remove `@cloudflare/next-on-pages` (if necessary)
94+
95+
If your Next.js app currently uses `@cloudflare/next-on-pages`, you'll want to remove it, and make a few changes.
96+
9397
#### Remove `export const runtime = "edge";`
9498

9599
Before deploying your app, remove the `export const runtime = "edge";` line from your `next.config.js` file. This line is not needed when using `@opennextjs/cloudflare`.
@@ -98,7 +102,28 @@ Before deploying your app, remove the `export const runtime = "edge";` line from
98102

99103
You should add `.worker-next` to your `.gitignore` file to prevent the build output from being committed to your repository.
100104

101-
#### Uninstall next-on-pages
105+
#### Remove references to `@cloudflare/next-on-pages`:
106+
107+
You no longer need to call `setupDevPlatform()` in your `next.config.mjs` file:
108+
109+
```diff title="next.config.mjs"
110+
- import { setupDevPlatform } from '@cloudflare/next-on-pages/next-dev';
111+
112+
/** @type {import('next').NextConfig} */
113+
const nextConfig = {};
114+
115+
- if (process.env.NODE_ENV === 'development') {
116+
- await setupDevPlatform();
117+
- }
118+
119+
And you'll want to replace any uses of `getRequestContext` from `@cloudflare/next-on-pages` with `getCloudflareContext` from `@opennextjs/cloudflare`:
120+
121+
```diff
122+
- import { getRequestContext } from "@cloudflare/next-on-pages";
123+
+ import { getCloudflareContext } from "@opennextjs/cloudflare";
124+
```
125+
126+
#### Uninstall `@cloudflare/next-on-pages`
102127

103128
You should uninstall `@cloudflare/next-on-pages` and remove any references to it.
104129

@@ -111,9 +136,7 @@ You should uninstall `@cloudflare/next-on-pages` and remove any references to it
111136
"devDependencies": {
112137
- "@cloudflare/next-on-pages": "*",
113138
```
114-
(remember to also remove the eslint-plugin-next-on-pages from your `.eslintrc.js` file)
115-
116-
Be sure to search through any other files in your project for references to `@cloudflare/next-on-pages` and remove them.
139+
(remember to also remove [eslint-plugin-next-on-pages](https://www.npmjs.com/package/eslint-plugin-next-on-pages) from your `.eslintrc.js` file)
117140

118141
##### 5. Develop locally
119142

@@ -129,4 +152,4 @@ Either deploy via the command line:
129152
npm run deploy:worker
130153
```
131154

132-
Or [connect a Github or Gitlab repository](https://developers.cloudflare.com/workers/ci-cd/), and Cloudflare will automatically build and deploy each pull request you merge to your production branch.
155+
Or [connect a Github or Gitlab repository](https://developers.cloudflare.com/workers/ci-cd/), and Cloudflare will automatically build and deploy each pull request you merge to your production branch.

0 commit comments

Comments
 (0)