diff --git a/.alexrc b/.alexrc
index 47862f2c80a1..1f1de4b4382a 100644
--- a/.alexrc
+++ b/.alexrc
@@ -17,6 +17,7 @@
"hooks",
"host-hostess",
"invalid",
- "remains"
+ "remains",
+ "white"
]
}
diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml
index b22bb436c1c3..fd346920c8d6 100644
--- a/.github/workflows/build_test_deploy.yml
+++ b/.github/workflows/build_test_deploy.yml
@@ -1060,7 +1060,7 @@ jobs:
build-native-test:
name: Build native binary for tests and metrics
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-latest
steps:
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
@@ -1092,14 +1092,14 @@ jobs:
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
with:
path: ~/.cargo/registry
- key: stable-ubuntu-18.04-cargo-registry
+ key: stable-ubuntu-latest-cargo-registry
- name: Cache cargo index
uses: actions/cache@v3
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
with:
path: ~/.cargo/git
- key: stable-ubuntu-18.04-cargo-index
+ key: stable-ubuntu-latest-cargo-index
# We use week in the turbo cache key to keep the cache from infinitely growing
- id: get-week
@@ -1125,9 +1125,9 @@ jobs:
uses: actions/cache@v3
with:
path: ./packages/next-swc/target
- key: next-swc-cargo-cache-dev-ubuntu-18.04-${{ hashFiles('**/Cargo.lock') }}
+ key: next-swc-cargo-cache-dev-ubuntu-latest-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
- next-swc-cargo-cache-dev-ubuntu-18.04
+ next-swc-cargo-cache-dev-ubuntu-latest
# since the repo's dependencies aren't installed we need
# to install napi globally
@@ -1152,7 +1152,7 @@ jobs:
test-native:
name: Unit Test Native Code
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@@ -1176,7 +1176,7 @@ jobs:
test-wasm:
name: Test the wasm build
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-latest
needs: [build, build-native-test, build-wasm-dev]
steps:
@@ -1294,7 +1294,7 @@ jobs:
export CC_aarch64_unknown_linux_gnu=/usr/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc &&
turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-gnu &&
llvm-strip -x packages/next-swc/native/next-swc.*.node
- - host: ubuntu-18.04
+ - host: ubuntu-latest
target: 'armv7-unknown-linux-gnueabihf'
setup: |
sudo apt-get update
@@ -1357,7 +1357,7 @@ jobs:
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
- if: ${{ matrix.settings.host == 'ubuntu-18.04' }}
+ if: ${{ matrix.settings.host == 'ubuntu-latest' }}
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off
if: ${{ matrix.settings.host == 'ubuntu-latest' }}
diff --git a/.github/workflows/pull_request_stats.yml b/.github/workflows/pull_request_stats.yml
index 0971e1b6221e..5a9dc25f116d 100644
--- a/.github/workflows/pull_request_stats.yml
+++ b/.github/workflows/pull_request_stats.yml
@@ -13,7 +13,7 @@ env:
jobs:
build-native-dev:
name: Build dev binary for tests
- runs-on: ubuntu-18.04
+ runs-on: ubuntu-latest
steps:
# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
@@ -46,14 +46,14 @@ jobs:
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
with:
path: ~/.cargo/registry
- key: stable-ubuntu-18.04-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
+ key: stable-ubuntu-latest-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
if: ${{ steps.docs-change.outputs.DOCS_CHANGE == 'nope' }}
with:
path: ~/.cargo/git
- key: stable-ubuntu-18.04-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
+ key: stable-ubuntu-latest-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
# We use week in the turbo cache key to keep the cache from infinitely growing
- id: get-week
@@ -78,9 +78,9 @@ jobs:
uses: actions/cache@v3
with:
path: ./packages/next-target
- key: next-swc-cargo-cache-ubuntu-18.04--${{ hashFiles('**/Cargo.lock') }}
+ key: next-swc-cargo-cache-ubuntu-latest--${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
- next-swc-cargo-cache-ubuntu-18.04
+ next-swc-cargo-cache-ubuntu-latest
# since the repo's dependencies aren't installed we need
# to install napi globally
diff --git a/.prettierignore_staged b/.prettierignore_staged
index 44fcc6dab75a..41755b6a33ae 100644
--- a/.prettierignore_staged
+++ b/.prettierignore_staged
@@ -7,5 +7,6 @@ packages/next/bundles/webpack/packages/*.runtime.js
lerna.json
packages/next-codemod/transforms/__testfixtures__/**/*
packages/next-codemod/transforms/__tests__/**/*
-pnpm-lock.yaml
-.github/actions/issue-validator/index.mjs
\ No newline at end of file
+pnpm-lock.yam
+.github/actions/issue-validator/index.mjs
+**/convex/_generated/**
\ No newline at end of file
diff --git a/contributing.md b/contributing.md
index 6238e972f4bf..b3ec843cf2e7 100644
--- a/contributing.md
+++ b/contributing.md
@@ -61,7 +61,7 @@ pnpm build
pnpm prepublishOnly
```
-By default the latest canary of the next-swc binaries will be installed and used. If you are actively working on Rust code or you need to test out the most recent Rust code that hasn't been published as a canary yet you can [install Rust](https://www.rust-lang.org/tools/install) and run `pnpm --filter=@next/swc build-native`.
+By default, the latest canary of the next-swc binaries will be installed and used. If you are actively working on Rust code or you need to test out the most recent Rust code that hasn't been published as a canary yet you can [install Rust](https://www.rust-lang.org/tools/install) and run `pnpm --filter=@next/swc build-native`.
If you want to test out the wasm build locally, you will need to [install wasm-pack](https://rustwasm.github.io/wasm-pack/installer/). Run `pnpm --filter=@next/swc build-wasm --target ` to build and `node ./scripts/setup-wasm.mjs` to copy it into your `node_modules`. Run next with `NODE_OPTIONS='--no-addons'` to force it to use the wasm binary.
@@ -164,7 +164,7 @@ There are two options to develop with your local version of the codebase:
to re-install all of the dependencies.
- Note that Next will be copied from the locally compiled version as opposed to from being downloaded from the NPM registry.
+ Note that Next will be copied from the locally compiled version as opposed to being downloaded from the NPM registry.
4. Run your application as you normally would.
@@ -263,7 +263,7 @@ Below are the steps to add a new link:
## Adding examples
-When you add an example to the [examples](examples) directory, please follow these guidelines to ensure high quality examples:
+When you add an example to the [examples](examples) directory, please follow these guidelines to ensure high-quality examples:
- TypeScript should be leveraged for new examples (no need for separate JavaScript and TypeScript examples, converting old JavaScript examples is preferred)
- Examples should not add custom ESLint configuration (we have specific templates for ESLint)
@@ -277,7 +277,7 @@ When you add an example to the [examples](examples) directory, please follow the
- Example directories should not be prefixed with `with-`
- Make sure linting passes (you can run `pnpm lint-fix`)
-Also don’t forget to add a `README.md` file with the following format:
+Also, don’t forget to add a `README.md` file with the following format:
- Replace `DIRECTORY_NAME` with the directory name you’re adding.
- Fill in `Example Name` and `Description`.
@@ -333,7 +333,7 @@ Issues are opened with one of these labels:
- `template: bug` - unverified issue with Next.js itself, or one of the examples in the [`examples`](https://github.com/vercel/next.js/tree/canary/examples) folder
- `template: documentation` - feedback for improvement or an unverified issue with the Next.js documentation
-In case of a bug report, a maintainer looks at the provided reproduction. If the reproduction is missing or insufficient, a `please add a complete reproduction` label is added. If a reproduction is not provided for more than 30 days, the issue becomes stale and will be automatically closed. If a reproduction is provided within 30 days, the `please add a complete reproduction` label is removed and the issue will not become stale anymore.
+In the case of a bug report, a maintainer looks at the provided reproduction. If the reproduction is missing or insufficient, a `please add a complete reproduction` label is added. If a reproduction is not provided for more than 30 days, the issue becomes stale and will be automatically closed. If a reproduction is provided within 30 days, the `please add a complete reproduction` label is removed and the issue will not become stale anymore.
Bug reports must be verified against the `next@canary` release. The canary version of Next.js ships daily and includes all features and fixes that have not been released to the stable version yet. Think of canary as a public beta. Some issues may already be fixed in the canary version, so please verify that your issue reproduces before opening a new issue. Issues not verified against `next@canary` will be closed after 30 days.
@@ -341,6 +341,6 @@ If the issue is specific to the project and not to Next.js itself, it might be c
If the bug is verified, it will receive the `kind: bug` label and will be tracked by the maintainers. An `area:` label can be added to indicate which part of Next.js is affected.
-Confirmed issues never become stale or be closed before resolution.
+Confirmed issues never become stale or are closed before resolution.
All **closed** PRs and Issues will be locked after 30 days of inactivity (eg.: comment, referencing from elsewhere).
diff --git a/docs/advanced-features/custom-error-page.md b/docs/advanced-features/custom-error-page.md
index e3f4b2ddf79d..6b3a2b860b1b 100644
--- a/docs/advanced-features/custom-error-page.md
+++ b/docs/advanced-features/custom-error-page.md
@@ -98,3 +98,4 @@ If you have a custom `Error` component be sure to import that one instead. `next
### Caveats
- `Error` does not currently support Next.js [Data Fetching methods](/docs/basic-features/data-fetching.md) like [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) or [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md).
+- `_error`, like `_app`, is a reserved pathname. `_error` is used to define the customized layouts and behaviors of the error pages. `/_error` will render 404 when accessed directly via [routing](/docs/routing/introduction) or rendering in a [custom server](/docs/advanced-features/custom-server).
diff --git a/docs/advanced-features/preview-mode.md b/docs/advanced-features/preview-mode.md
index a6700718692d..e9cd56f40f61 100644
--- a/docs/advanced-features/preview-mode.md
+++ b/docs/advanced-features/preview-mode.md
@@ -173,6 +173,8 @@ https:///api/preview?secret=&slug=
## More Details
+> **Note**: during rendering `next/router` exposes an `isPreview` flag, see the [router object docs](/docs/api-reference/next/router.md#router-object) for more info.
+
### Clear the Preview Mode cookies
By default, no expiration date is set for Preview Mode cookies, so the preview session ends when the browser is closed.
diff --git a/docs/advanced-features/react-18/server-components.md b/docs/advanced-features/react-18/server-components.md
index fb6699fba26c..839bda3274a3 100644
--- a/docs/advanced-features/react-18/server-components.md
+++ b/docs/advanced-features/react-18/server-components.md
@@ -1,30 +1,18 @@
-# React Server Components (Alpha)
+# React Server Components (RFC)
Server Components allow us to render React components on the server. This is fundamentally different from server-side rendering (SSR) where you're pre-generating HTML on the server. With Server Components, there's **zero client-side JavaScript needed,** making page rendering faster. This improves the user experience of your application, pairing the best parts of server-rendering with client-side interactivity.
-### Enable React Server Components
+### Next Router and Layouts RFC
-To use React Server Components, ensure you have the latest React installed:
+We are currently implementing the [Next.js Router and Layouts RFC](/blog/layouts-rfc).
-```jsx
-npm install next@canary react@latest react-dom@latest
-```
-
-Then, update your `next.config.js`:
+The new Next.js router will be built on top of React 18 features, including React Server Components.
-```jsx
-// next.config.js
-module.exports = {
- experimental: {
- runtime: 'nodejs',
- serverComponents: true,
- },
-}
-```
+One of the biggest proposed changes is that, by default, files inside a new `app` directory will be rendered on the server as React Server Components.
-Using `runtime` also enables [Streaming SSR](/docs/advanced-features/react-18/streaming). When setting `runtime` to `'experimental-edge'`, the server will be running entirely in the [Edge Runtime](https://nextjs.org/docs/api-reference/edge-runtime).
+This will allow you to automatically adopt React Server Components when migrating from `pages` to `app`.
-Now, you can start using React Server Components in Next.js. [See our example](https://github.com/vercel/next-rsc-demo) for more information.
+You can find more information on the [RFC](/blog/layouts-rfc) and we welcome your feedback on [Github Discussions](https://github.com/vercel/next.js/discussions/37136).
### Server Components Conventions
diff --git a/docs/advanced-features/static-html-export.md b/docs/advanced-features/static-html-export.md
index a2a7a7f2b80a..107a348a4f3f 100644
--- a/docs/advanced-features/static-html-export.md
+++ b/docs/advanced-features/static-html-export.md
@@ -31,6 +31,8 @@ Running `npm run build` will generate an `out` directory.
For more advanced scenarios, you can define a parameter called [`exportPathMap`](/docs/api-reference/next.config.js/exportPathMap.md) in your [`next.config.js`](/docs/api-reference/next.config.js/introduction.md) file to configure exactly which pages will be generated.
+> **Warning**: Using `exportPathMap` for defining routes with any `getStaticPaths` powered page is now ignored and gets overridden. We recommend not to use them together.
+
## Supported Features
The majority of core Next.js features needed to build a static site are supported, including:
diff --git a/docs/api-reference/next.config.js/exportPathMap.md b/docs/api-reference/next.config.js/exportPathMap.md
index a1ef9f65021f..4180363e6dcf 100644
--- a/docs/api-reference/next.config.js/exportPathMap.md
+++ b/docs/api-reference/next.config.js/exportPathMap.md
@@ -40,7 +40,7 @@ module.exports = {
}
```
-Note: the `query` field in `exportPathMap` cannot be used with [automatically statically optimized pages](/docs/advanced-features/automatic-static-optimization) or [`getStaticProps` pages](/docs/basic-features/data-fetching/get-static-props.md) as they are rendered to HTML files at build-time and additional query information cannot be provided during `next export`.
+> Note: the `query` field in `exportPathMap` cannot be used with [automatically statically optimized pages](/docs/advanced-features/automatic-static-optimization) or [`getStaticProps` pages](/docs/basic-features/data-fetching/get-static-props.md) as they are rendered to HTML files at build-time and additional query information cannot be provided during `next export`.
The pages will then be exported as HTML files, for example, `/about` will become `/about.html`.
@@ -79,6 +79,8 @@ module.exports = {
next export -o outdir
```
+> **Warning**: Using `exportPathMap` for defining routes with any `getStaticPaths` powered page is now ignored and gets overridden. We recommend not to use them together.
+
## Related
diff --git a/docs/api-reference/next.config.js/introduction.md b/docs/api-reference/next.config.js/introduction.md
index 994c5c78cfc5..e708004bd1a2 100644
--- a/docs/api-reference/next.config.js/introduction.md
+++ b/docs/api-reference/next.config.js/introduction.md
@@ -80,7 +80,7 @@ module.exports = (phase, { defaultConfig }) => {
}
```
-The commented lines are the place where you can put the configs allowed by `next.config.js`, which are [defined in this file](https://github.com/vercel/next.js/blob/canary/packages/next/server/config-shared.ts#L137).
+The commented lines are the place where you can put the configs allowed by `next.config.js`, which are [defined in this file](https://github.com/vercel/next.js/blob/canary/packages/next/server/config-shared.ts#L158).
However, none of the configs are required, and it's not necessary to understand what each config does. Instead, search for the features you need to enable or modify in this section and they will show you what to do.
diff --git a/docs/api-reference/next.config.js/redirects.md b/docs/api-reference/next.config.js/redirects.md
index 988a5fa97522..05b50a62a3d7 100644
--- a/docs/api-reference/next.config.js/redirects.md
+++ b/docs/api-reference/next.config.js/redirects.md
@@ -300,4 +300,4 @@ In some rare cases, you might need to assign a custom status code for older HTTP
## Other Redirects
- Inside [API Routes](/docs/api-routes/response-helpers.md), you can use `res.redirect()`.
-- Inside [`getStaticProps`](/docs/basic-features/data-fetching/get-static-props.md) and [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md), you can redirect specific pages at request-time.
+- Inside [`getStaticProps`](/docs/api-reference/data-fetching/get-static-props.md) and [`getServerSideProps`](/docs/api-reference/data-fetching/get-server-side-props.md), you can redirect specific pages at request-time.
diff --git a/docs/api-reference/next/future/image.md b/docs/api-reference/next/future/image.md
index f7909d6bcec6..aeeacf7eac26 100644
--- a/docs/api-reference/next/future/image.md
+++ b/docs/api-reference/next/future/image.md
@@ -16,7 +16,7 @@ description: Try the latest Image Optimization with the experimental `next/futur
The `next/future/image` component is an experiment to improve both the performance and developer experience of `next/image` by using the native `` element with better default behavior.
-This new component is considered experimental and therefore not covered by semver, and may cause unexpected or broken application behavior. This component uses browser native [lazy loading](https://caniuse.com/loading-lazy-attr), which may fallback to eager loading for older browsers before Safari 15.4. When using the blur-up placeholder, older browsers before Safari 12 will fallback to empty placeholder. When using styles with `width`/`height` of `auto`, it is possible to cause [Layout Shift](https://web.dev/cls/) on older browsers before [Chrome 79](https://chromestatus.com/feature/5695266130755584), [Firefox 69](https://bugzilla.mozilla.org/show_bug.cgi?id=1547231), and [Safari 14.2](https://bugs.webkit.org/show_bug.cgi?id=201641). For more details, see [this MDN video](https://www.youtube.com/watch?v=4-d_SoCHeWE).
+This new component is considered experimental and therefore not covered by semver, and may cause unexpected or broken application behavior. This component uses browser native [lazy loading](https://caniuse.com/loading-lazy-attr), which may fallback to eager loading for older browsers before Safari 15.4. When using the blur-up placeholder, older browsers before Safari 12 will fallback to empty placeholder. When using styles with `width`/`height` of `auto`, it is possible to cause [Layout Shift](https://web.dev/cls/) on older browsers before Safari 15 that don't [preserve the aspect ratio](https://caniuse.com/mdn-html_elements_img_aspect_ratio_computed_from_attributes). For more details, see [this MDN video](https://www.youtube.com/watch?v=4-d_SoCHeWE).
To use `next/future/image`, add the following to your `next.config.js` file:
@@ -34,12 +34,24 @@ module.exports = {
Compared to `next/image`, the new `next/future/image` component has the following changes:
-- Renders a single `` without `
` or `` wrappers
+- Removes `` wrapper around `` in favor of [native computed aspect ratio](https://caniuse.com/mdn-html_elements_img_aspect_ratio_computed_from_attributes)
- Adds support for canonical `style` prop
-- Removes `layout`, `objectFit`, and `objectPosition` props in favor of `style` or `className`
+ - Removes `layout` prop in favor of `style` or `className`
+ - Removes `objectFit` prop in favor of `style` or `className`
+ - Removes `objectPosition` prop in favor of `style` or `className`
- Removes `IntersectionObserver` implementation in favor of [native lazy loading](https://caniuse.com/loading-lazy-attr)
+ - Removes `lazyBoundary` prop since there is no native equivalent
+ - Removes `lazyRoot` prop since there is no native equivalent
- Removes `loader` config in favor of [`loader`](#loader) prop
-- Note: the [`onError`](#onerror) prop might behave differently
+
+## Known Browser Bugs
+
+- [Safari 15+](https://bugs.webkit.org/show_bug.cgi?id=243601) displays a gray border while loading. Possible solutions:
+ - Use CSS `@media not all and (min-resolution:.001dpcm) { img[loading="lazy"] { clip-path: inset(0.5px) } }`
+ - Use [`priority`](#priority) if the image is above the fold
+- [Firefox 67+](https://bugzilla.mozilla.org/show_bug.cgi?id=1556156) displays a white background while loading progressive jpeg. Possible solutions:
+ - Enable [AVIF `formats`](#acceptable-formats)
+ - Use [`placeholder="blur"`](#blur)
## Migration
@@ -303,7 +315,7 @@ The callback function will be called with one argument, an object with the follo
A callback function that is invoked when the image is loaded.
-Note that the load event might occur before client-side hydration completes, so this callback might not be invoked in that case.
+Note that the load event might occur before the placeholder is removed and the image is fully decoded.
Instead, use [`onLoadingComplete`](#onloadingcomplete).
@@ -311,8 +323,6 @@ Instead, use [`onLoadingComplete`](#onloadingcomplete).
A callback function that is invoked if the image fails to load.
-Note that the error might occur before client-side hydration completes, so this callback might not be invoked in that case.
-
### loading
> **Attention**: This property is only meant for advanced usage. Switching an
diff --git a/docs/basic-features/font-optimization.md b/docs/basic-features/font-optimization.md
index bcd1498072fa..139a09b32d5d 100644
--- a/docs/basic-features/font-optimization.md
+++ b/docs/basic-features/font-optimization.md
@@ -53,7 +53,13 @@ class MyDocument extends Document {
export default MyDocument
```
-Note that we don't recommend adding fonts with `next/head`, as this only applies the font to the particular page and won't work with a streaming architecture.
+Although it's possible to add fonts in a page with [`next/head`](/docs/api-reference/next/head) it comes with some drawbacks:
+
+- It only applies the font to that particular page.
+- The font optimization will only work on page load, not on client side navigation.
+- It won't work with a streaming architecture.
+
+Thus it's highly recommended to add the font in a [Custom `Document`](/docs/advanced-features/custom-document.md), like in the code snippet above.
Automatic Webfont Optimization currently supports Google Fonts and Typekit with support for other font providers coming soon. We're also planning to add control over [loading strategies](https://github.com/vercel/next.js/issues/21555) and `font-display` values.
diff --git a/docs/basic-features/layouts.md b/docs/basic-features/layouts.md
index 5afa956ec29e..394169e9f0a6 100644
--- a/docs/basic-features/layouts.md
+++ b/docs/basic-features/layouts.md
@@ -128,7 +128,7 @@ import type { ReactElement, ReactNode } from 'react'
import type { NextPage } from 'next'
import type { AppProps } from 'next/app'
-export type NextPageWithLayout = NextPage & {
+export type NextPageWithLayout
= NextPage
& {
getLayout?: (page: ReactElement) => ReactNode
}
diff --git a/docs/basic-features/pages.md b/docs/basic-features/pages.md
index 519e8a18bece..46314a3ac16c 100644
--- a/docs/basic-features/pages.md
+++ b/docs/basic-features/pages.md
@@ -41,7 +41,7 @@ Importantly, Next.js lets you **choose** which pre-rendering form you'd like to
We **recommend** using **Static Generation** over Server-side Rendering for performance reasons. Statically generated pages can be cached by CDN with no extra configuration to boost performance. However, in some cases, Server-side Rendering might be the only option.
-You can also use **Client-side Rendering** along with Static Generation or Server-side Rendering. That means some parts of a page can be rendered entirely by client side JavaScript. To learn more, take a look at the [Data Fetching](/docs/basic-features/data-fetching/client-side.md) documentation.
+You can also use **Client-side data fetching** along with Static Generation or Server-side Rendering. That means some parts of a page can be rendered entirely by client side JavaScript. To learn more, take a look at the [Data Fetching](/docs/basic-features/data-fetching/client-side.md) documentation.
## Static Generation (Recommended)
@@ -217,7 +217,7 @@ On the other hand, Static Generation is **not** a good idea if you cannot pre-re
In cases like this, you can do one of the following:
-- Use Static Generation with **Client-side Rendering:** You can skip pre-rendering some parts of a page and then use client-side JavaScript to populate them. To learn more about this approach, check out the [Data Fetching documentation](/docs/basic-features/data-fetching/client-side.md).
+- Use Static Generation with **Client-side data fetching:** You can skip pre-rendering some parts of a page and then use client-side JavaScript to populate them. To learn more about this approach, check out the [Data Fetching documentation](/docs/basic-features/data-fetching/client-side.md).
- Use **Server-Side Rendering:** Next.js pre-renders a page on each request. It will be slower because the page cannot be cached by a CDN, but the pre-rendered page will always be up-to-date. We'll talk about this approach below.
## Server-side Rendering
diff --git a/docs/faq.md b/docs/faq.md
index fe9ca6838034..216db88c40ce 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -14,7 +14,7 @@ description: Get to know more about Next.js with the frequently asked questions.
How do I fetch data in Next.js?
Next.js provides a variety of methods depending on your use case. You can use:
-
Client-side rendering: Fetch data with useEffect or SWR inside your React components
+
Client-side data fetching: Fetch data with useEffect or SWR inside your React components
diff --git a/errors/invalid-dynamic-suspense.md b/errors/invalid-dynamic-suspense.md
index 11e4d6134d73..f016eec897d4 100644
--- a/errors/invalid-dynamic-suspense.md
+++ b/errors/invalid-dynamic-suspense.md
@@ -2,11 +2,29 @@
#### Why This Error Occurred
-`` is not allowed under legacy render mode when using React older than v18.
+- You are using `{ suspense: true }` with React version older than 18.
+- You are using `{ suspense: true, ssr: false }`.
+- You are using `{ suspense: true, loading }`.
#### Possible Ways to Fix It
-Remove `suspense: true` option in `next/dynamic` usages.
+**If you are using `{ suspense: true }` with React version older than 18**
+
+- You can try upgrading to React 18 or newer
+- If upgrading React is not an option, remove `{ suspense: true }` from `next/dynamic` usages.
+
+**If you are using `{ suspense: true, ssr: false }`**
+
+Next.js will use `React.lazy` when `suspense` is set to true. React 18 or newer will always try to resolve the Suspense boundary on the server. This behavior can not be disabled, thus the `ssr: false` is ignored with `suspense: true`.
+
+- You should write code that works in both client-side and server-side.
+- If rewriting the code is not an option, remove `{ suspense: true }` from `next/dynamic` usages.
+
+**If you are using `{ suspense: true, loading }`**
+
+Next.js will use `React.lazy` when `suspense` is set to true, when your dynamic-imported component is loading, React will use the closest suspense boundary's fallback.
+
+You should remove `loading` from `next/dynamic` usages, and use ``'s `fallback` prop.
### Useful Links
diff --git a/examples/auth-with-stytch/pages/_document.tsx b/examples/auth-with-stytch/pages/_document.tsx
index 83d9080a67d7..496f4c465e5c 100644
--- a/examples/auth-with-stytch/pages/_document.tsx
+++ b/examples/auth-with-stytch/pages/_document.tsx
@@ -1,33 +1,18 @@
-import Document, {
- Html,
- Head,
- Main,
- NextScript,
- DocumentContext,
-} from 'next/document'
+import { Html, Head, Main, NextScript } from 'next/document'
-class MyDocument extends Document {
- static async getInitialProps(ctx: DocumentContext) {
- const initialProps = await Document.getInitialProps(ctx)
- return { ...initialProps }
- }
-
- render() {
- return (
-
-
-
-
-
-
-
-
-
- )
- }
+export default function Document() {
+ return (
+
+
+
+
+
+
+
+
+
+ )
}
-
-export default MyDocument
diff --git a/examples/blog-starter/pages/_document.tsx b/examples/blog-starter/pages/_document.tsx
index c55951c0d5da..54e8bf3e2a29 100644
--- a/examples/blog-starter/pages/_document.tsx
+++ b/examples/blog-starter/pages/_document.tsx
@@ -1,15 +1,13 @@
-import Document, { Html, Head, Main, NextScript } from 'next/document'
+import { Html, Head, Main, NextScript } from 'next/document'
-export default class MyDocument extends Document {
- render() {
- return (
-
-
-
-
-
-
-
- )
- }
+export default function Document() {
+ return (
+
+