Skip to content

Commit 6bf5a8a

Browse files
authored
docs: document the next/dynamic case with ssr: false option (#69741)
1 parent 38e6206 commit 6bf5a8a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

docs/02-app/01-building-your-application/06-optimizing/07-lazy-loading.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export default function ClientComponentExample() {
5959

6060
When using `React.lazy()` and Suspense, Client Components will be pre-rendered (SSR) by default.
6161

62+
> **Note:** `ssr: false` option will only work for client components, move it into client components ensure the client code-splitting working properly.
63+
6264
If you want to disable pre-rendering for a Client Component, you can use the `ssr` option set to `false`:
6365

6466
```jsx
@@ -68,6 +70,9 @@ const ComponentC = dynamic(() => import('../components/C'), { ssr: false })
6870
### Importing Server Components
6971

7072
If you dynamically import a Server Component, only the Client Components that are children of the Server Component will be lazy-loaded - not the Server Component itself.
73+
It will also help preload the static assets such as CSS when you're using it in Server Components.
74+
75+
> **Note:** `ssr: false` option is not supported in Server Components.
7176
7277
```jsx filename="app/page.js"
7378
import dynamic from 'next/dynamic'
@@ -202,6 +207,8 @@ const DynamicComponent = dynamic(() =>
202207
To dynamically load a component on the client side, you can use the `ssr` option to disable server-rendering. This is useful if an external dependency or component relies on browser APIs like `window`.
203208

204209
```jsx
210+
'use client'
211+
205212
import dynamic from 'next/dynamic'
206213

207214
const DynamicHeader = dynamic(() => import('../components/header'), {

0 commit comments

Comments
 (0)