Skip to content

Commit 3bff0dd

Browse files
update workers Next.js guide to work on @opennextjs/[email protected]
1 parent 98f2a91 commit 3bff0dd

File tree

1 file changed

+17
-7
lines changed
  • src/content/docs/workers/frameworks/framework-guides

1 file changed

+17
-7
lines changed

src/content/docs/workers/frameworks/framework-guides/nextjs.mdx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ import { WranglerConfig } from "~/components";
7070
<WranglerConfig>
7171

7272
```toml
73-
main = ".worker-next/index.mjs"
73+
main = ".open-next/worker.js"
7474
name = "my-app"
7575
compatibility_date = "2024-09-23"
7676
compatibility_flags = ["nodejs_compat"]
77-
assets = { directory = ".worker-next/assets", binding = "ASSETS" }
77+
assets = { directory = ".open-next/assets", binding = "ASSETS" }
7878
```
7979

8080
</WranglerConfig>
@@ -90,7 +90,7 @@ As shown above, you must enable the [`nodejs_compat` compatibility flag](/worker
9090
Add the following to the scripts field of your `package.json` file:
9191

9292
```json
93-
"build:worker": "cloudflare",
93+
"build:worker": "opennextjs-cloudflare",
9494
"dev:worker": "wrangler dev --port 8771",
9595
"preview:worker": "npm run build:worker && npm run dev:worker",
9696
"deploy:worker": "npm run build:worker && wrangler deploy"
@@ -115,8 +115,6 @@ npx wrangler@latest kv namespace create NEXT_CACHE_WORKERS_KV
115115

116116
#### Add the KV namespace to your Worker
117117

118-
119-
120118
<WranglerConfig>
121119

122120
```toml
@@ -135,9 +133,21 @@ As shown above, the name of the binding that you configure for the KV namespace
135133

136134
You can continue to run `next dev` when developing locally.
137135

138-
In step 3, we also added the `npm run preview:worker`, which allows you to quickly preview your app running locally in the Workers runtime, rather than in Node.js. This allows you to test changes in the same runtime that your app runs in, when deployed to Cloudflare.
136+
### 6. Preview locally your application and create an OpenNext config file
137+
138+
In step 3, we also added the `npm run preview:worker`, which allows you to quickly preview your app running locally in the Workers runtime, rather than in Node.js.
139+
This allows you to test changes in the same runtime that your app runs in, when deployed to Cloudflare.
140+
141+
To preview your application in such way run:
142+
143+
```sh
144+
npm run preview:worker
145+
```
146+
147+
This command will build your OpenNext application, also creating, if not already present, an `open-next.configs.ts` file for you.
148+
This if necessary if you want to deploy your application with a GibHub/GitLab integration as presented in the next step.
139149

140-
### 6. Deploy to Cloudflare Workers
150+
### 7. Deploy to Cloudflare Workers
141151

142152
Either deploy via the command line:
143153

0 commit comments

Comments
 (0)