From 7b8016af74ffe963707d17d5ad3cea02769ad744 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Wed, 5 Feb 2025 10:00:07 +0100 Subject: [PATCH 1/3] mark pages router as supported --- pages/cloudflare/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/cloudflare/index.mdx b/pages/cloudflare/index.mdx index 63644f8..e5c3a9c 100644 --- a/pages/cloudflare/index.mdx +++ b/pages/cloudflare/index.mdx @@ -52,8 +52,8 @@ We will update the list as we progress towards releasing 1.0. - [x] [Middleware](https://nextjs.org/docs/app/building-your-application/routing/middleware) - [x] [Image optimization](https://nextjs.org/docs/app/building-your-application/optimizing/images) (you can integrate Cloudflare Images with Next.js by following [this guide](https://developers.cloudflare.com/images/transform-images/integrate-with-frameworks/)) - [x] [Partial Prerendering (PPR)](https://nextjs.org/docs/app/building-your-application/rendering/partial-prerendering) +- [x] [Pages Router](https://nextjs.org/docs/pages) - [ ] [Support for after](https://nextjs.org/blog/next-15-rc#executing-code-after-a-response-with-nextafter-experimental) -- [ ] [Pages Router](https://nextjs.org/docs/pages) - [ ] [Incremental Static Regeneration (ISR)](https://nextjs.org/docs/app/building-your-application/data-fetching/incremental-static-regeneration) - [ ] [Composable Caching](https://nextjs.org/blog/composable-caching) (`'use cache'`) is a Next.js 15 feature and not supported yet. From 5b85198b25e0456e9d34a6886242bdbaa2e3eeec Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Wed, 5 Feb 2025 10:05:40 +0100 Subject: [PATCH 2/3] simplify npm scripts, align with the c3 template --- pages/cloudflare/get-started.mdx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/pages/cloudflare/get-started.mdx b/pages/cloudflare/get-started.mdx index ad5fbf1..8f97fca 100644 --- a/pages/cloudflare/get-started.mdx +++ b/pages/cloudflare/get-started.mdx @@ -128,16 +128,12 @@ The `NEXTJS_ENV` variable defines the environment to use when loading Next.js `. Add the following to the scripts field of your `package.json` file: ```json -"build:worker": "opennextjs-cloudflare", -"dev:worker": "wrangler dev --port 8771", -"preview": "npm run build:worker && npm run dev:worker", -"deploy": "npm run build:worker && wrangler deploy", -"cf-typegen": "wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts", +"preview": "npx opennextjs-cloudflare && npx wrangler dev", +"deploy": "npx opennextjs-cloudflare && npx wrangler deploy", +"cf-typegen": "npx wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts", ``` -- `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. -- `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. -- `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. +- `npm run preview`: Builds your app and serves it locally, allowing you to quickly preview your app running locally in the Workers runtime, via a single command. - `npm run deploy`: Builds your app, and then deploys it to Cloudflare - `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). @@ -193,7 +189,7 @@ export default nextConfig; After having added the `initOpenNextCloudflareForDev()` call in your Next.js configuration file, you will be able, during local development, to access in any of your server code, local versions of Cloudflare bindings as indicated in the [bindings documentation](./bindings). -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, +In step 3, we also added the `npm run preview`, 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 as your app will run in when deployed to Cloudflare. ##### 12. Deploy to Cloudflare Workers @@ -201,7 +197,7 @@ rather than in Node.js. This allows you to test changes in the same runtime as y Either deploy via the command line: ```sh -npm run deploy:worker +npm run deploy ``` 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. From 298fa4d42b11ebebc0f1a2fd6f391803aaa57f91 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Wed, 5 Feb 2025 12:39:21 +0100 Subject: [PATCH 3/3] Update pages/cloudflare/get-started.mdx --- pages/cloudflare/get-started.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/cloudflare/get-started.mdx b/pages/cloudflare/get-started.mdx index 8f97fca..8f20c2c 100644 --- a/pages/cloudflare/get-started.mdx +++ b/pages/cloudflare/get-started.mdx @@ -128,9 +128,9 @@ The `NEXTJS_ENV` variable defines the environment to use when loading Next.js `. Add the following to the scripts field of your `package.json` file: ```json -"preview": "npx opennextjs-cloudflare && npx wrangler dev", -"deploy": "npx opennextjs-cloudflare && npx wrangler deploy", -"cf-typegen": "npx wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts", +"preview": "opennextjs-cloudflare && wrangler dev", +"deploy": "opennextjs-cloudflare && wrangler deploy", +"cf-typegen": "wrangler types --env-interface CloudflareEnv cloudflare-env.d.ts", ``` - `npm run preview`: Builds your app and serves it locally, allowing you to quickly preview your app running locally in the Workers runtime, via a single command.