Skip to content

Commit 9758666

Browse files
IgorMinarvicb
andauthored
docs: improve repo and npm package README.md files (#32)
* docs: improve repo and npm package README.md files * fixup! --------- Co-authored-by: Victor Berchet <[email protected]>
1 parent 42bf0ff commit 9758666

File tree

2 files changed

+50
-19
lines changed

2 files changed

+50
-19
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
# [POC] Build Next.js app for cf workers
1+
# Deploy Next.js apps to Cloudflare
22

3-
This monorepo includes a package for adapting a Next.js application built via `next build` (in standalone mode) to run in the Cloudflare workerd runtime.
3+
OpenNext for Cloudflare is Cloudflare specific adapter that enables deployment of Next.js applications to Cloudflare.
44

5-
> [!NOTE]
6-
> The code here is built based on the amazing work done by @mhart in <https://github.com/mhart/nextjs-commerce>
5+
This monorepo includes a package for adapting a Next.js application built via `next build` (in standalone mode) to run in the Cloudflare workerd runtime using the [Workers Node.js compatibility layer](https://developers.cloudflare.com/workers/runtime-apis/nodejs/).
76

8-
## The repository
7+
## Get started
8+
9+
Follow instructions at [`@opennextjs/cloudflare`](https://www.npmjs.com/package/@opennextjs/cloudflare).
10+
11+
## Contributing
12+
13+
### The repository
914

1015
The repository contains two directories:
1116

1217
- `packages` containing a cloudflare package that can be used to build Cloudflare workers compatible output from Next.js applications
1318
- `examples` containing Next.js applications that use the above mentioned cloudflare.
1419

15-
## How to try out/develop in the repository
20+
### How to try out/develop in the repository
1621

1722
Install the dependencies:
1823

packages/cloudflare/README.md

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,65 @@
1-
# Next.js builder for Cloudflare
1+
# OpenNext for Cloudflare
22

3-
How to update a Next.js application to run on Cloudflare.
3+
Deploy Next.js apps to Cloudflare!
44

5-
## Configure your app
5+
OpenNext for Cloudflare is Cloudflare specific adapter that enables deployment of Next.js applications to Cloudflare.
66

7-
- add the following `devDependencies` to the `package.json`:
7+
## Getting started
88

9-
```bash
10-
pnpm add -D wrangler@latest @opennextjs/cloudflare
11-
```
9+
You can use [`create-next-app`](https://nextjs.org/docs/pages/api-reference/cli/create-next-app) to start a new application or take an existing Next.js application and deploy it to Cloudflare using the following few steps:
1210

13-
## Serve your app
11+
## Configure your app
1412

15-
- build the app and adapt it for Cloudflare
13+
- add the following `devDependencies` to the `package.json`:
1614

1715
```bash
18-
pnpx cloudflare
16+
pnpm add -D wrangler@latest @opennextjs/cloudflare
1917
```
2018

2119
- add a `wrangler.toml` at the root of your project
2220

2321
```toml
2422
#:schema node_modules/wrangler/config-schema.json
25-
name = "<app-name>"
23+
name = "<your-app-name>"
2624
main = ".worker-next/index.mjs"
2725

28-
compatibility_date = "2024-08-29"
29-
compatibility_flags = ["nodejs_compat_v2"]
26+
compatibility_date = "2024-09-23"
27+
compatibility_flags = ["nodejs_compat"]
3028

3129
# Use the new Workers + Assets to host the static frontend files
3230
experimental_assets = { directory = ".worker-next/assets", binding = "ASSETS" }
3331
```
3432

33+
## Local development
34+
35+
- you can use the regular `next` CLI to start the Next.js dev server:
36+
37+
## Local preview
38+
39+
Run the following commands to preview the production build of your application locally:
40+
41+
- build the app and adapt it for Cloudflare
42+
43+
```bash
44+
pnpx cloudflare
45+
```
46+
3547
- Preview the app in Wrangler
3648

3749
```bash
3850
pnpm wrangler dev
3951
```
52+
53+
## Deploy your app
54+
55+
Deploy your application to production with the following:
56+
57+
- build the app and adapt it for Cloudflare
58+
59+
```bash
60+
pnpx cloudflare
61+
```
62+
63+
```bash
64+
pnpm wrangler deploy
65+
```

0 commit comments

Comments
 (0)