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
-[Developer's Certificate of Origin 1.1](#developers-certificate-of-origin-11)
@@ -164,6 +165,48 @@ This repository contains several scripts and commands for performing numerous ta
164
165
165
166
</details>
166
167
168
+
## Experimental Cloudflare Deployment
169
+
170
+
The website is in the process of being fully migrated and served from the [Cloudflare](https://www.cloudflare.com) network via [Cloudflare Workers](https://www.cloudflare.com/en-gb/developer-platform/products/workers/) using the [OpenNext Cloudflare adapter](https://opennext.js.org/cloudflare).
171
+
172
+
Such migration is still in its experimental phase and is being gradually rolled out.
173
+
174
+
### Scripts
175
+
176
+
For the time being preview and deployment of the website targeting the Cloudflare network
177
+
is implemented via the following two scripts:
178
+
179
+
- `npx turbo 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/))
180
+
- `npx turbo 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/))
181
+
182
+
### Configurations
183
+
184
+
There are two types of configurations that relate to Cloudflare.
185
+
186
+
#### Wrangler Configuration
187
+
188
+
This is the configuration for the Cloudflare Worker that refers to the artifacts being
189
+
built by the OpenNext adapter. For more details on such configuration please refer to
190
+
the [official Cloudflare documentation](https://developers.cloudflare.com/workers/wrangler/configuration/).
191
+
192
+
The the most important configurations to keep in mind are:
193
+
194
+
- `main` points to the worker generated by the OpenNext adapter
195
+
- `account_id` ID of the accounts to use to deploy the application
196
+
(this account ID doesn't matter for local development, for deployment external contributors can sign up for free at [dash.cloudflare.com](https://dash.cloudflare.com/login) and obtain an account id that they can use to deploy their own fork of the website)
197
+
- `build` build command used to generate Node.js fs polyfills needed for the application to run in a Cloudflare Worker (using the [`@flarelabs/wrangler-build-time-fs-assets-polyfilling`](https://www.npmjs.com/package/@flarelabs-net/wrangler-build-time-fs-assets-polyfilling) package)
198
+
- `alias` map of aliases for the Node.js fs polyfills generated by the `build` configuration
199
+
- `kv_namespaces` array containing a single KV binding definition for `NEXT_CACHE_WORKERS_KV`
200
+
this is a [KV binding](https://developers.cloudflare.com/kv/concepts/kv-bindings/) used to implement the Next.js incremental cache (again, external contributors can replace the KV ID with their own
201
+
that they can set up for free at [dash.cloudflare.com/kv/namespaces](https://dash.cloudflare.com/?to=/:account/workers/kv/namespaces))
202
+
203
+
#### OpenNext Configuration
204
+
205
+
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).
206
+
207
+
The configuration present here is very standard and simply sets up incremental cache via the KV binding
208
+
defined in the wrangler configuration file.
209
+
167
210
## Commit Guidelines
168
211
169
212
This project follows the [Conventional Commits][] specification.
0 commit comments