Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
// let assetPrefix = undefined;

///** Deploys as a directory through GitHub Actions **/
//const isGithubActions = process.env.GITHUB_ACTIONS || false
//const isGitHubActions = process.env.GITHUB_ACTIONS || false
//
//if (isGithubActions) {
//if (isGitHubActions) {
// // trim off `<owner>/`
// const repo = process.env.GITHUB_REPOSITORY.replace(/.*?\//, '')
//
Expand Down
2 changes: 1 addition & 1 deletion pages/aws/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ There is two build arguments that you can pass to the `open-next build` command:

### Configuration File

For personalisation you need to create a file `open-next.config.ts` at the same place as your `next.config.js`, and export a default object that satisfies the `OpenNextConfig` interface. It is possible to not have an `open-next.config.ts` file, the default configuration will then be applied automatically.
For personalization you need to create a file `open-next.config.ts` at the same place as your `next.config.js`, and export a default object that satisfies the `OpenNextConfig` interface. It is possible to not have an `open-next.config.ts` file, the default configuration will then be applied automatically.

This file needs to be placed at the same level as your `next.config.js` file.

Expand Down
2 changes: 1 addition & 1 deletion pages/aws/config/nx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default $config({
$ cd apps/next-site && sst install
```

this will resolve the type issues and initialise SST.
this will resolve the type issues and initialize SST.

- next we need to add `sst.config.ts` to our `tsconfig.json`'s excludes array

Expand Down
4 changes: 2 additions & 2 deletions pages/aws/contribute/plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ openNextPlugin({
deletes: ["id1"],
})

//To inject arbritary code by using (import at top of file):
//To inject arbitrary code by using (import at top of file):

//#import

Expand Down Expand Up @@ -63,7 +63,7 @@ openNextEdgePlugin({
nextDir: "next",
// The path to the edgeFunctionHandler.js file that we'll use to bundle the routing
edgeFunctionHandlerPath: "./edgeFunctionHandler.js",
// The middlewareInfo from the middlware manifest file
// The middlewareInfo from the middleware manifest file
middlewareInfo: middlewareInfo
// If the app should be bundled for cloudflare workers
isInCloudflare: true
Expand Down
2 changes: 1 addition & 1 deletion pages/aws/inner_workings/components/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Every backend is a separate module. The following backends are available:
- Warmer
- Initializer

All these backends can be overrided to fit your needs. They share some common ground for the configuration and the way they are used.
All these backends can be overridden to fit your needs. They share some common ground for the configuration and the way they are used.

### Common Overrides

Expand Down
2 changes: 1 addition & 1 deletion pages/aws/v2/inner_workings/plugin.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Callout } from "nextra/components";

Open-next use esbuild to build the project. Given that we aim to support multiple version of Next and multiple runtime, we developped a plugin to override some parts of our code at build time with an esbuild plugin.
Open-next use esbuild to build the project. Given that we aim to support multiple version of Next and multiple runtime, we developed a plugin to override some parts of our code at build time with an esbuild plugin.

<Callout type="warning" emoji="⚠️">
As of now, the plugin is internal and not exposed to the user. We might expose it in the future, but for
Expand Down
6 changes: 3 additions & 3 deletions pages/cloudflare/caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Tabs } from "nextra/components";

Next.js offers multiple ways to improve an application's performance by [caching](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#caching-data) routes and network requests. An application will try to pre-render and cache as much data as possible during build-time to reduce the amount of work required when serving a response to a user.

The cache data are updated using revalidation, either peridiocally or on-demand:
The cache data are updated using revalidation, either periodically or on-demand:

- "[Time-based revalidation](https://nextjs.org/docs/app/building-your-application/data-fetching/incremental-static-regeneration#time-based-revalidation)" updates the cache data after the revalidation delay specified by the applications expires
- "[On-demand revalidation](https://nextjs.org/docs/app/building-your-application/data-fetching/incremental-static-regeneration#on-demand-revalidation-with-revalidatetag)" allows to invalid cache entries with a specific tag (via `revalidateTag`) or at a given path (via `revalidatePath`). You can also use `res.revalidate` in Pages router API route.
Expand Down Expand Up @@ -585,9 +585,9 @@ export default defineCloudflareConfig({
});
```

##### 4. Initialise the cache during deployments
##### 4. Initialize the cache during deployments

In order for the cache to be properly initialised with the build-time revalidation data, you need to run a command as part of your deploy step. This should be run as part of each deployment to ensure that the cache is being populated with each build's data.
In order for the cache to be properly initialized with the build-time revalidation data, you need to run a command as part of your deploy step. This should be run as part of each deployment to ensure that the cache is being populated with each build's data.

To populate remote bindings and create a new [version](https://developers.cloudflare.com/workers/configuration/versions-and-deployments/#versions) of your application at the same time, you can use either the [`deploy`](/cloudflare/cli#deploy-command) command or the [`upload`](/cloudflare/cli#upload-command) command. Similarly, the [`preview`](/cloudflare/cli#preview-command) command will populate your local bindings and start a Wrangler dev server.

Expand Down
4 changes: 2 additions & 2 deletions pages/cloudflare/community.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Here is a list of some of the features it includes:
- Rate Limiting with Cloudflare KV to prevent abuse
- Validation for all user actions with react-zsa and zod
- Database: Drizzle ORM and Cloudflare D1
- UI: Shadcn, Tailwind CSS and Hero UI (formely NextUI)
- UI: `shadcn/ui`, Tailwind CSS and HeroUI (formerly NextUI)
- Transactional email templates with react-email and integration with Resend and Brevo
- Dev Experience
- Completely type safe
Expand All @@ -26,5 +26,5 @@ Here is a list of some of the features it includes:
- .cursorrules
- A markdown project documentation that Cursor can refer to for more context and better responses
- Detailed documentation for local development and production deployment
- Automatic deployment using Github Actions and the Wrangler CLI
- Automatic deployment using GitHub Actions and the Wrangler CLI
- And more...
2 changes: 1 addition & 1 deletion pages/cloudflare/former-releases/0.2/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ Either deploy via the command line:
npm run deploy:worker
```

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.
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.
2 changes: 1 addition & 1 deletion pages/cloudflare/former-releases/0.3/caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ By default, all `fetch()` subrequests made in your Next.js app are cached. Refer

Note that [Revalidating](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#revalidating-data) is not yet supported.

Next.js primes the cache at build time. The build time values are serverd by the [Workers Assets](https://developers.cloudflare.com/workers/static-assets/).
Next.js primes the cache at build time. The build time values are served by the [Workers Assets](https://developers.cloudflare.com/workers/static-assets/).

<Callout>
Workers KV is eventually consistent, which means that it can take up to 60 seconds for updates to be
Expand Down
2 changes: 1 addition & 1 deletion pages/cloudflare/former-releases/0.3/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,4 @@ Either deploy via the command line:
npm run deploy:worker
```

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.
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.
6 changes: 3 additions & 3 deletions pages/cloudflare/former-releases/0.5/caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Callout } from "nextra/components";

`@opennextjs/cloudflare` supports [caching](https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#caching-data).

Next.js primes the cache at build time. The build time values are serverd by the [Workers Assets](https://developers.cloudflare.com/workers/static-assets/).
Next.js primes the cache at build time. The build time values are served by the [Workers Assets](https://developers.cloudflare.com/workers/static-assets/).

<Callout>
Workers KV is eventually consistent, which means that it can take up to 60 seconds for updates to be
Expand Down Expand Up @@ -143,9 +143,9 @@ export default defineCloudflareConfig({
});
```

##### 4. Initialise the cache during deployments
##### 4. Initialize the cache during deployments

In order for the cache to be properly initialised with the build-time revalidation data, you need to setup a command that runs as part of your deploy step.
In order for the cache to be properly initialized with the build-time revalidation data, you need to setup a command that runs as part of your deploy step.

OpenNext will generate an SQL file during the build that can be used to setup your D1 database.

Expand Down
2 changes: 1 addition & 1 deletion pages/cloudflare/former-releases/0.5/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@ Either deploy via the command line:
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.
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.
6 changes: 3 additions & 3 deletions pages/cloudflare/former-releases/0.6/caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Tabs } from "nextra/components";

There are two storage options to use for the incremental cache.

- **Workers KV:** A [fast](https://blog.cloudflare.com/faster-workers-kv) and uses Cloudflare's [Tiered Cache](https://developers.cloudflare.com/cache/how-to/tiered-cache/) to increase cache hit rates. When you write cached data to Workers KV, you write to storage that can be read by any Cloudflare location. This means your app can fetch data, cache it in KV, and then subsequent requests anywhere around the world can read from this cache. The build time values are serverd by the [Workers Assets](https://developers.cloudflare.com/workers/static-assets/). Pricing information can be found in the Cloudflare [docs](https://developers.cloudflare.com/workers/platform/pricing/#workers-kv).
- **Workers KV:** A [fast](https://blog.cloudflare.com/faster-workers-kv) and uses Cloudflare's [Tiered Cache](https://developers.cloudflare.com/cache/how-to/tiered-cache/) to increase cache hit rates. When you write cached data to Workers KV, you write to storage that can be read by any Cloudflare location. This means your app can fetch data, cache it in KV, and then subsequent requests anywhere around the world can read from this cache. The build time values are served by the [Workers Assets](https://developers.cloudflare.com/workers/static-assets/). Pricing information can be found in the Cloudflare [docs](https://developers.cloudflare.com/workers/platform/pricing/#workers-kv).
- **R2 Object Storage:** A [cost-effective](https://developers.cloudflare.com/r2/pricing/) S3-compatible object storage option for large amounts of unstructured data. Data is stored in a single region, meaning cache interactions may be slower - this can be mitigated with a regional cache.

<Callout>
Expand Down Expand Up @@ -393,9 +393,9 @@ export default defineCloudflareConfig({
});
```

##### 3. Initialise the cache during deployments
##### 3. Initialize the cache during deployments

In order for the cache to be properly initialised with the build-time revalidation data, you need to run a command as part of your deploy step. This should be run as part of each deployment to ensure that the cache is being populated with each build's data.
In order for the cache to be properly initialized with the build-time revalidation data, you need to run a command as part of your deploy step. This should be run as part of each deployment to ensure that the cache is being populated with each build's data.

To populate remote bindings and deploy your application at the same time, you can use the `deploy` command. Similarly, the `preview` command will populate your local bindings and start a Wrangler dev server.

Expand Down
2 changes: 1 addition & 1 deletion pages/cloudflare/former-releases/0.6/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,4 @@ Either deploy via the command line:
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.
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.
2 changes: 1 addition & 1 deletion pages/cloudflare/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,4 @@ Either deploy via the command line:
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.
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.
2 changes: 1 addition & 1 deletion pages/cloudflare/howtos/dev-deploy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Use the `build` command followed by either `deploy` or `upload` to deploy your l
<Callout type="warning">
When running the `build` command locally, `.dev.vars` and [Next `.env`
files](https://nextjs.org/docs/pages/building-your-application/configuring/environment-variables) might
override your configuration. It is preferreable to use a CD system as [Workers
override your configuration. It is preferable to use a CD system as [Workers
Builds](https://developers.cloudflare.com/workers/ci-cd/builds/) to deploy your application for reproducible
deployments.
</Callout>
Expand Down
2 changes: 1 addition & 1 deletion pages/cloudflare/howtos/env-vars.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Callout } from "nextra/components";

This entry describe the most sensible way to handle your environment variables which works well both during local development and once your application is deployed to Cloudflare Workers.

On the Cloudflare platform, your environment variables can be stored in either ["Enviroment variables"](https://developers.cloudflare.com/workers/configuration/environment-variables/) or ["Secrets"](https://developers.cloudflare.com/workers/configuration/secrets/). The difference being that Secrets can not be read back from either the dashboard or the CLI after being created.
On the Cloudflare platform, your environment variables can be stored in either ["Environment variables"](https://developers.cloudflare.com/workers/configuration/environment-variables/) or ["Secrets"](https://developers.cloudflare.com/workers/configuration/secrets/). The difference being that Secrets can not be read back from either the dashboard or the CLI after being created.

### Local development

Expand Down
2 changes: 1 addition & 1 deletion pages/cloudflare/howtos/keep_names.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enables the [`keep-names`](https://esbuild.github.io/api/#keep-names) option. Wh
cause issues with certain Next.js libraries (e.g. [next-themes](https://www.npmjs.com/package/next-themes)) that convert scripts
to strings. This happens because `esbuild` introduces a `__name` function at the top of modules, which may inadvertently appear
in the generated script strings. When these strings are evaluated at runtime, the `__name` function might therefore not be defined,
leading to errors logged in the developper console:
leading to errors logged in the developer console:

```
Uncaught ReferenceError: __name is not defined
Expand Down
2 changes: 1 addition & 1 deletion pages/cloudflare/howtos/multi-worker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ The steps to deploy without causing downtime to the already deployed ones are as
9. You then deploy the middleware at 100% `wrangler versions deploy <NEW_MIDDLEWARE_ID>@100% -y --config ./path-to/middlewareWrangler.jsonc`. At this stage you are already serving the new version of the website in production.
10. To finish it off you deploy the server at 100% `wrangler versions deploy <NEW_SERVER_VERSION_ID>@100% -y --config ./path-to/server-wrangler.jsonc`.

You can find actual implementations of such a deployment in the GitBook repo using Github actions [here](https://github.com/GitbookIO/gitbook/blob/main/.github/composite/deploy-cloudflare/action.yaml).
You can find actual implementations of such a deployment in the GitBook repo using GitHub actions [here](https://github.com/GitbookIO/gitbook/blob/main/.github/composite/deploy-cloudflare/action.yaml).

#### Version Affinity Explained

Expand Down
4 changes: 2 additions & 2 deletions pages/cloudflare/howtos/skew.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default {
// Maximum number of previous versions to use.
// Optional, default to 20.
maxNumberOfVersions: 20,
// Age of the oldest version to use (from the last deplyment date)
// Age of the oldest version to use (from the last deployment date)
// Optional, default to 7 days.
maxVersionAgeDays: 7,
},
Expand Down Expand Up @@ -68,7 +68,7 @@ and the process' environment variables. If a variable is set in both places, the

**Next config**

You must set a different `deploymentId` in your next config each time your app is deployed. You will get an error if the `deployementId` has already been used by a previous deployment.
You must set a different `deploymentId` in your next config each time your app is deployed. You will get an error if the `deploymentId` has already been used by a previous deployment.

The cloudflare adapter exports a `getDeploymentId()` function that can be used to generate a unique deployment id.

Expand Down
2 changes: 1 addition & 1 deletion pages/cloudflare/perf.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The Incremental cache is the store containing all the cached data (i.e. pages, `

You should use the Workers Static Assets based cache if your site is SSG. It is the fastest available option. Note that as Workers Static Assets are read-only, this option can not be used with revalidation.

When your app uses re-validation, use the R2 based store instead. We recommend the following settings to get the best perfomance:
When your app uses re-validation, use the R2 based store instead. We recommend the following settings to get the best performance:

- use regional cache by wrapping the handler into `withRegionalCache(...)`
- use the `long-lived` mode
Expand Down