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.
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.
It will also help preload the static assets such as CSS when you're using it in Server Components.
It will also help preload the static assets such as CSS when you're using it in Server Components.
> **Note:** `ssr: false` option is not supported in Server Components.
```jsx filename="app/page.js"
```jsx filename="app/page.js"
import dynamic from 'next/dynamic'
import dynamic from 'next/dynamic'
...
@@ -89,6 +87,9 @@ export default function ServerComponentExample() {
...
@@ -89,6 +87,9 @@ export default function ServerComponentExample() {
}
}
```
```
> **Note:** `ssr: false` option is not supported in Server Components. You will see an error if you try to use it in Server Components.
> `ssr: false` is not allowed with `next/dynamic` in Server Components. Please move it into a client component.
### Loading External Libraries
### Loading External Libraries
External libraries can be loaded on demand using the [`import()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/import) function. This example uses the external library `fuse.js` for fuzzy search. The module is only loaded on the client after the user types in the search input.
External libraries can be loaded on demand using the [`import()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/import) function. This example uses the external library `fuse.js` for fuzzy search. The module is only loaded on the client after the user types in the search input.