dynamic()fromnext/dynamic— the primary API for lazy loading in the App Router.React.lazy()withSuspense— works in Client Components.
dynamic()
next/dynamic is a combination of React.lazy() and Suspense. It works in both Server and Client Components.
Basic usage
Loading UI
Show a fallback while the component loads:Disabling SSR
To prevent a component from rendering on the server, usessr: false. This is useful for components that depend on browser APIs:
Named exports
To lazy load a named export from a module, return it from thePromise returned by the dynamic import:
Lazy loading libraries
Third-party libraries can also be loaded on demand usingimport() inside an event handler:
app/page.tsx
React.lazy() with Suspense
Inside Client Components, you can use React.lazy() and Suspense directly:
app/page.tsx
dynamic() from next/dynamic supports additional options like ssr: false that React.lazy() does not. Prefer dynamic() for full Next.js feature support.dynamic() options reference
function
required
A function that returns a
Promise resolving to the component module. Usually an import() call.function
A component to render while the dynamic component is loading.
boolean
default:"true"
Whether to server-side render the component. Set to
false to skip SSR for browser-only components.