-
Notifications
You must be signed in to change notification settings - Fork 72
docs: improve repo and npm package README.md files #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,65 @@ | ||
# Next.js builder for Cloudflare | ||
# OpenNext for Cloudflare | ||
|
||
How to update a Next.js application to run on Cloudflare. | ||
Deploy Next.js apps to Cloudflare! | ||
vicb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Configure your app | ||
OpenNext for Cloudflare is Cloudflare specific adapter that enables deployment of Next.js applications to Cloudflare. | ||
|
||
- add the following `devDependencies` to the `package.json`: | ||
## Getting started | ||
|
||
```bash | ||
pnpm add -D wrangler@latest @opennextjs/cloudflare | ||
``` | ||
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: | ||
|
||
## Serve your app | ||
## Configure your app | ||
|
||
- build the app and adapt it for Cloudflare | ||
- add the following `devDependencies` to the `package.json`: | ||
|
||
```bash | ||
pnpx cloudflare | ||
pnpm add -D wrangler@latest @opennextjs/cloudflare | ||
``` | ||
|
||
- add a `wrangler.toml` at the root of your project | ||
|
||
```toml | ||
#:schema node_modules/wrangler/config-schema.json | ||
name = "<app-name>" | ||
name = "<your-app-name>" | ||
main = ".worker-next/index.mjs" | ||
|
||
compatibility_date = "2024-08-29" | ||
compatibility_flags = ["nodejs_compat_v2"] | ||
compatibility_date = "2024-09-23" | ||
compatibility_flags = ["nodejs_compat"] | ||
|
||
# Use the new Workers + Assets to host the static frontend files | ||
experimental_assets = { directory = ".worker-next/assets", binding = "ASSETS" } | ||
``` | ||
|
||
## Local development | ||
|
||
- you can use the regular `next` CLI to start the Next.js dev server: | ||
|
||
## Local preview | ||
|
||
Run the following commands to preview the production build of your application locally: | ||
|
||
- build the app and adapt it for Cloudflare | ||
|
||
```bash | ||
pnpx cloudflare | ||
``` | ||
|
||
- Preview the app in Wrangler | ||
|
||
```bash | ||
pnpm wrangler dev | ||
``` | ||
|
||
## Deploy your app | ||
|
||
Deploy your application to production with the following: | ||
|
||
- build the app and adapt it for Cloudflare | ||
|
||
```bash | ||
pnpx cloudflare | ||
``` | ||
|
||
```bash | ||
pnpm wrangler deploy | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.