Skip to content

Commit 4f91a0a

Browse files
authored
doc(cloudflare): updates (#50)
1 parent b1ab51d commit 4f91a0a

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

pages/cloudflare/caching.mdx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ npx wrangler@latest kv namespace create <YOUR_NAMESPACE_NAME>
3333

3434
The binding name used in your app's worker is `NEXT_CACHE_WORKERS_KV`.
3535

36-
```
37-
[[kv_namespaces]]
38-
binding = "NEXT_CACHE_WORKERS_KV"
39-
id = "<YOUR_NAMESPACE_ID>"
36+
```jsonc
37+
// wrangler.json
38+
{
39+
// ...
40+
"kv_namespaces": [
41+
{
42+
"binding": "NEXT_CACHE_WORKERS_KV",
43+
"id": "<BINDING_ID>"
44+
}
45+
]
46+
}
4047
```

pages/cloudflare/get-started.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,16 @@ Add the following to the scripts field of your `package.json` file:
129129
```json
130130
"build:worker": "opennextjs-cloudflare",
131131
"dev:worker": "wrangler dev --port 8771",
132-
"preview:worker": "npm run build:worker && npm run dev:worker",
133-
"deploy:worker": "npm run build:worker && wrangler deploy"
132+
"preview": "npm run build:worker && npm run dev:worker",
133+
"deploy": "npm run build:worker && wrangler deploy",
134+
"cf-typegen": "wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts",
134135
```
135136

136137
- `npm run build:worker`: Runs the [@opennextjs/cloudflare](https://www.npmjs.com/package/@opennextjs/cloudflare) adapter. This first builds your app by running the `build` script in your `package.json` (Next.js apps use `next build` by default), and then transforms the build output to a format that you can run locally using [Wrangler](https://developers.cloudflare.com/workers/wrangler/), and deploy to Cloudflare. The build command used by OpenNext can be overridden with the `buildCommand` option in your OpenNext config.
137138
- `npm run dev:worker`: Takes the output generated by `build:worker` and runs it locally in [workerd](https://github.com/cloudflare/workerd), the open-source Workers Runtime, allowing you to run the app locally in the same environment that it will run in production. If you instead run `next dev`, your app will run in Node.js, which is a different JavaScript runtime from the Workers runtime, with differences in behavior and APIs.
138-
- `npm run preview:worker`: Runs `build:worker` and then `dev:worker`, allowing you to quickly preview your app running locally in the Workers runtime, via a single command.
139+
- `npm run preview`: Runs `build:worker` and then `dev:worker`, allowing you to quickly preview your app running locally in the Workers runtime, via a single command.
139140
- `npm run deploy`: Builds your app, and then deploys it to Cloudflare
141+
- `cf-typegen`: Generates a `cloudflare-env.d.ts` file at the root of your project containing [the types for the `env`](https://developers.cloudflare.com/workers/wrangler/commands/#types).
140142

141143
##### 7. Add caching with Workers KV
142144

0 commit comments

Comments
 (0)