You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
make site work with the Cloudflare OpenNext adapter
update the site application so that it can be build using the
Cloudflare OpenNext adapter (`@opennextjs/cloudflare`) and thus
deployed on Cloudflare Workers
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ Thank you for your interest in contributing to the Node.js Website. Before you p
7
7
-[Becoming a collaborator](#becoming-a-collaborator)
8
8
-[Getting started](#getting-started)
9
9
-[CLI Commands](#cli-commands)
10
+
-[Cloudflare Deployment](#cloudflare-deployment)
10
11
-[Commit Guidelines](#commit-guidelines)
11
12
-[Pull Request Policy](#pull-request-policy)
12
13
-[Developer's Certificate of Origin 1.1](#developers-certificate-of-origin-11)
@@ -165,6 +166,42 @@ This repository contains several scripts and commands for performing numerous ta
165
166
166
167
</details>
167
168
169
+
## Cloudflare Deployment
170
+
171
+
The Node.js Website can be deployed to the [Cloudflare](https://www.cloudflare.com) network using [Cloudflare Workers](https://www.cloudflare.com/en-gb/developer-platform/products/workers/) and the [OpenNext Cloudflare adapter](https://opennext.js.org/cloudflare). This section provides the necessary details for testing and deploying the website on Cloudflare.
172
+
173
+
### Scripts
174
+
175
+
Preview and deployment of the website targeting the Cloudflare network is implemented via the following two commands:
176
+
177
+
- `pnpm cloudflare:preview` builds the website using the OpenNext Cloudflare adapter and runs the website locally in a server simulating the Cloudflare hosting (using the [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/))
178
+
- `pnpm cloudflare:deploy` builds the website using the OpenNext Cloudflare adapter and deploys the website to the Cloudflare network (using the [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/))
179
+
180
+
### Configurations
181
+
182
+
There are two key configuration files related to Cloudflare deployment.
183
+
184
+
#### Wrangler Configuration
185
+
186
+
This file defines the settings for the Cloudflare Worker, which serves the website.
187
+
188
+
For more details, refer to the [Wrangler documentation](https://developers.cloudflare.com/workers/wrangler/configuration/).
189
+
190
+
Key configurations include:
191
+
192
+
- `main`: Points to the worker generated by the OpenNext adapter.
193
+
- `account_id`: Specifies the Cloudflare account ID. This is not required forlocal previews but is necessary for deployments. You can obtain an account ID for free by signing up at [dash.cloudflare.com](https://dash.cloudflare.com/login).
194
+
- `build`: Defines the build command to generate Node.js filesystem polyfills required for the application to run on Cloudflare Workers. This uses the [`@flarelabs/wrangler-build-time-fs-assets-polyfilling`](https://github.com/flarelabs-net/wrangler-build-time-fs-assets-polyfilling) package.
195
+
- `alias`: Maps aliases for the Node.js filesystem polyfills generated during the build process.
196
+
- `kv_namespaces`: Contains a single KV binding definition for`NEXT_CACHE_WORKERS_KV`. This is used to implement the Next.js incremental cache. For deployments, you can create a new KV namespacein the Cloudflare dashboard and update the binding ID accordingly.
197
+
198
+
#### OpenNext Configuration
199
+
200
+
This is the configuration for the OpenNext Cloudflare adapter, for more details on such configuration please refer to the [official OpenNext documentation](https://opennext.js.org/cloudflare/get-started#4-add-an-open-nextconfigts-file).
201
+
202
+
The configuration present here is very standard and simply sets up incremental cache via the KV binding
203
+
defined in the wrangler configuration file.
204
+
168
205
## Commit Guidelines
169
206
170
207
This project follows the [Conventional Commits][] specification.
0 commit comments