Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .github/labeler.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
{ "type": "user", "pattern": "leerob" },
{ "type": "user", "pattern": "manovotny" },
{ "type": "user", "pattern": "molebox" },
{ "type": "user", "pattern": "timeyoutakeit" }
{ "type": "user", "pattern": "timeyoutakeit" },
{ "type": "user", "pattern": "icyJoseph" }
],
"created-by: Turbopack team": [
{ "type": "user", "pattern": "bgw" },
Expand Down
1 change: 1 addition & 0 deletions docs/01-app/01-getting-started/06-css.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ function ExampleDialog(props) {
```

</PagesOnly>

## Ordering and Merging

Next.js optimizes CSS during production builds by automatically chunking (merging) stylesheets. The **order of your CSS** depends on the **order you import styles in your code**.
Expand Down
4 changes: 2 additions & 2 deletions docs/01-app/01-getting-started/07-partial-prerendering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ const nextConfig = {

The `'incremental'` value allows you to adopt PPR for specific routes:

```tsx filename="/app/dashboard/layout.tsx" highlight={3}
```tsx filename="/app/dashboard/layout.tsx"
export const experimental_ppr = true

export default function Layout({ children }: { children: React.ReactNode }) {
// ...
}
```

```jsx filename="/app/dashboard/layout.js" highlight={3}
```jsx filename="/app/dashboard/layout.js"
export const experimental_ppr = true

export default function Layout({ children }) {
Expand Down
4 changes: 2 additions & 2 deletions docs/01-app/02-guides/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ const secretKey = process.env.SESSION_SECRET

#### 2. Encrypting and decrypting sessions

Next, you can use your preferred [session management library](#session-management-libraries) to encrypt and decrypt sessions. Continuing from the previous example, we'll use [Jose](https://www.npmjs.com/package/jose) (compatible with the [Edge Runtime](/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes)) and React's [`server-only`](https://www.npmjs.com/package/server-only) package to ensure that your session management logic is only executed on the server.
Next, you can use your preferred [session management library](#session-management-libraries) to encrypt and decrypt sessions. Continuing from the previous example, we'll use [Jose](https://www.npmjs.com/package/jose) (compatible with the [Edge Runtime](/docs/app/api-reference/edge)) and React's [`server-only`](https://www.npmjs.com/package/server-only) package to ensure that your session management logic is only executed on the server.

```tsx filename="app/lib/session.ts" switcher
import 'server-only'
Expand Down Expand Up @@ -1121,7 +1121,7 @@ While Middleware can be useful for initial checks, it should not be your only li
> **Tips**:
>
> - In Middleware, you can also read cookies using `req.cookies.get('session').value`.
> - Middleware uses the [Edge Runtime](/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes), check if your Auth library and session management library are compatible.
> - Middleware uses the [Edge Runtime](/docs/app/api-reference/edge), check if your Auth library and session management library are compatible.
> - You can use the `matcher` property in the Middleware to specify which routes Middleware should run on. Although, for auth, it's recommended Middleware runs on all routes.

<AppOnly>
Expand Down
2 changes: 1 addition & 1 deletion docs/01-app/02-guides/instrumentation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function register() {

### Importing runtime-specific code

Next.js calls `register` in all environments, so it's important to conditionally import any code that doesn't support specific runtimes (e.g. [Edge or Node.js](/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes)). You can use the `NEXT_RUNTIME` environment variable to get the current environment:
Next.js calls `register` in all environments, so it's important to conditionally import any code that doesn't support specific runtimes (e.g. [Edge or Node.js](/docs/app/api-reference/edge)). You can use the `NEXT_RUNTIME` environment variable to get the current environment:

```ts filename="instrumentation.ts" switcher
export async function register() {
Expand Down
2 changes: 1 addition & 1 deletion docs/01-app/02-guides/self-hosting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Image Optimization can be used with a [static export](/docs/app/guides/static-ex

[Middleware](/docs/app/building-your-application/routing/middleware) works self-hosted with zero configuration when deploying using `next start`. Since it requires access to the incoming request, it is not supported when using a [static export](/docs/app/guides/static-exports).

Middleware uses a [runtime](/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes) that is a subset of all available Node.js APIs to help ensure low latency, since it may run in front of every route or asset in your application. If you do not want this, you can use the [full Node.js runtime](/blog/next-15-2#nodejs-middleware-experimental) to run Middleware.
Middleware uses the [Edge runtime](/docs/app/api-reference/edge), a subset of all available Node.js APIs to help ensure low latency, since it may run in front of every route or asset in your application. If you do not want this, you can use the [full Node.js runtime](/blog/next-15-2#nodejs-middleware-experimental) to run Middleware.

If you are looking to add logic (or use an external package) that requires all Node.js APIs, you might be able to move this logic to a [layout](/docs/app/building-your-application/routing/layouts-and-templates#layouts) as a [Server Component](/docs/app/building-your-application/rendering/server-components). For example, checking [headers](/docs/app/api-reference/functions/headers) and [redirecting](/docs/app/api-reference/functions/redirect). You can also use headers, cookies, or query parameters to [redirect](/docs/app/api-reference/config/next-config-js/redirects#header-cookie-and-query-matching) or [rewrite](/docs/app/api-reference/config/next-config-js/rewrites#header-cookie-and-query-matching) through `next.config.js`. If that does not work, you can also use a [custom server](/docs/pages/guides/custom-server).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Runtime type-checking will still ensure you don't accidentally pass a function t
- Behind the scenes, actions use the `POST` method, and only this HTTP method can invoke them.
- The arguments and return value of Server Actions must be serializable by React. See the React docs for a list of [serializable arguments and values](https://react.dev/reference/react/use-server#serializable-parameters-and-return-values).
- Server Actions are functions. This means they can be reused anywhere in your application.
- Server Actions inherit the [runtime](/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes) from the page or layout they are used on.
- Server Actions inherit the runtime from the page or layout they are used on.
- Server Actions inherit the [Route Segment Config](/docs/app/api-reference/file-conventions/route-segment-config) from the page or layout they are used on, including fields like `maxDuration`.

## Examples
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Middleware can use the [`NextResponse`](/docs/app/building-your-application/rout

## Runtime

Middleware only supports the [Edge runtime](/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes). The Node.js runtime cannot be used.
Middleware uses [Edge runtime](/docs/app/api-reference/edge) by default. If you do not want this, you can use the [full Node.js runtime](/blog/next-15-2#nodejs-middleware-experimental) to run Middleware.

## Version History

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const fetchCache = 'auto'

### `runtime`

We recommend using the Node.js runtime for rendering your application, and the Edge runtime for Middleware (only supported option).
We recommend using the Node.js runtime for rendering your application, and the Edge runtime for Middleware.

```tsx filename="layout.tsx | page.tsx | route.ts" switcher
export const runtime = 'nodejs'
Expand All @@ -176,8 +176,6 @@ export const runtime = 'nodejs'
- **`'nodejs'`** (default)
- **`'edge'`**

Learn more about the [different runtimes](/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes).

### `preferredRegion`

```tsx filename="layout.tsx | page.tsx | route.ts" switcher
Expand Down
12 changes: 6 additions & 6 deletions docs/01-app/05-api-reference/05-config/03-eslint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ next lint --dir pages --dir utils --file bar.js

If you're using `eslint-plugin-next` in a project where Next.js isn't installed in your root directory (such as a monorepo), you can tell `eslint-plugin-next` where to find your Next.js application using the `settings` property in your `.eslintrc`:

```mjs filename="eslint.config.mjs"
```js filename="eslint.config.mjs"
import { FlatCompat } from '@eslint/eslintrc'

const compat = new FlatCompat({
Expand Down Expand Up @@ -108,7 +108,7 @@ next lint --no-cache

If you would like to modify or disable any rules provided by the supported plugins (`react`, `react-hooks`, `next`), you can directly change them using the `rules` property in your `.eslintrc`:

```mjs filename="eslint.config.mjs"
```js filename="eslint.config.mjs"
import { FlatCompat } from '@eslint/eslintrc'

const compat = new FlatCompat({
Expand All @@ -133,7 +133,7 @@ export default eslintConfig

The `next/core-web-vitals` rule set is enabled when `next lint` is run for the first time and the **strict** option is selected.

```mjs filename="eslint.config.mjs"
```js filename="eslint.config.mjs"
import { FlatCompat } from '@eslint/eslintrc'

const compat = new FlatCompat({
Expand All @@ -158,7 +158,7 @@ export default eslintConfig

In addition to the Next.js ESLint rules, `create-next-app --typescript` will also add TypeScript-specific lint rules with `next/typescript` to your config:

```mjs filename="eslint.config.mjs"
```js filename="eslint.config.mjs"
import { FlatCompat } from '@eslint/eslintrc'

const compat = new FlatCompat({
Expand Down Expand Up @@ -196,7 +196,7 @@ bun add --dev eslint-config-prettier

Then, add `prettier` to your existing ESLint config:

```mjs filename="eslint.config.mjs"
```js filename="eslint.config.mjs"
import { FlatCompat } from '@eslint/eslintrc'

const compat = new FlatCompat({
Expand Down Expand Up @@ -305,7 +305,7 @@ This eliminates the risk of collisions or errors that can occur due to importing

If you already use a separate ESLint configuration and want to include `eslint-config-next`, ensure that it is extended last after other configurations. For example:

```mjs filename="eslint.config.mjs"
```js filename="eslint.config.mjs"
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'

Expand Down
31 changes: 22 additions & 9 deletions docs/01-app/05-api-reference/07-edge.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@ description: API Reference for the Edge Runtime.

{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}

The Next.js Edge Runtime is used for Middleware and supports the following APIs:
Next.js has two server runtimes you can use in your application:

## Network APIs
- The **Node.js Runtime** (default), which has access to all Node.js APIs and is used for rendering your application.
- The **Edge Runtime** which contains a more limited [set of APIs](#reference), used in [Middleware](/docs/app/api-reference/file-conventions/middleware).

## Caveats

- The Edge Runtime does not support all Node.js APIs. Some packages may not work as expected.
- The Edge Runtime does not support Incremental Static Regeneration (ISR).
- Both runtimes can support [streaming](/docs/app/building-your-application/routing/loading-ui-and-streaming) depending on your deployment adapter.

## Reference

The Edge Runtime supports the following APIs:

### Network APIs

| API | Description |
| ------------------------------------------------------------------------------- | --------------------------------- |
Expand All @@ -22,7 +35,7 @@ The Next.js Edge Runtime is used for Middleware and supports the following APIs:
| [`URLSearchParams`](https://developer.mozilla.org/docs/Web/API/URLSearchParams) | Represents URL search parameters |
| [`WebSocket`](https://developer.mozilla.org/docs/Web/API/WebSocket) | Represents a websocket connection |

## Encoding APIs
### Encoding APIs

| API | Description |
| ----------------------------------------------------------------------------------- | ---------------------------------- |
Expand All @@ -33,7 +46,7 @@ The Next.js Edge Runtime is used for Middleware and supports the following APIs:
| [`TextEncoder`](https://developer.mozilla.org/docs/Web/API/TextEncoder) | Encodes a string into a Uint8Array |
| [`TextEncoderStream`](https://developer.mozilla.org/docs/Web/API/TextEncoderStream) | Chainable encoder for streams |

## Stream APIs
### Stream APIs

| API | Description |
| ------------------------------------------------------------------------------------------------------- | --------------------------------------- |
Expand All @@ -44,15 +57,15 @@ The Next.js Edge Runtime is used for Middleware and supports the following APIs:
| [`WritableStream`](https://developer.mozilla.org/docs/Web/API/WritableStream) | Represents a writable stream |
| [`WritableStreamDefaultWriter`](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter) | Represents a writer of a WritableStream |

## Crypto APIs
### Crypto APIs

| API | Description |
| ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| [`crypto`](https://developer.mozilla.org/docs/Web/API/Window/crypto) | Provides access to the cryptographic functionality of the platform |
| [`CryptoKey`](https://developer.mozilla.org/docs/Web/API/CryptoKey) | Represents a cryptographic key |
| [`SubtleCrypto`](https://developer.mozilla.org/docs/Web/API/SubtleCrypto) | Provides access to common cryptographic primitives, like hashing, signing, encryption or decryption |

## Web Standard APIs
### Web Standard APIs

| API | Description |
| --------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down Expand Up @@ -120,15 +133,15 @@ The Next.js Edge Runtime is used for Middleware and supports the following APIs:
| [`WeakSet`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) | Represents a collection of objects in which each object may occur only once |
| [`WebAssembly`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly) | Provides access to WebAssembly |

## Next.js Specific Polyfills
### Next.js Specific Polyfills

- [`AsyncLocalStorage`](https://nodejs.org/api/async_context.html#class-asynclocalstorage)

## Environment Variables
### Environment Variables

You can use `process.env` to access [Environment Variables](/docs/app/guides/environment-variables) for both `next dev` and `next build`.

## Unsupported APIs
### Unsupported APIs

The Edge Runtime has some restrictions including:

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion errors/invalid-page-config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ export const config = {}

- [Enabling AMP Support](/docs/pages/guides/amp)
- [API Routes Request Helpers](/docs/pages/building-your-application/routing/api-routes)
- [Edge and Node.js Runtimes](/docs/pages/building-your-application/rendering/edge-and-nodejs-runtimes)
- [Edge Runtime](/docs/app/api-reference/edge)
Loading
Loading