- Client-Side Code Splitting:
React.lazy
is a React feature introduced in version 16.6 that allows you to render a dynamic import as a regular component. It is primarily used for code splitting and lazy loading components in the client-side environment.
- Suspense Integration: It must be used in conjunction with the
Suspense
component, which lets you specify the loading indicator while the lazy-loaded component is being fetched.
- Limitations:
React.lazy
andSuspense
are not yet available for server-side rendering in React. This means that if you're usingReact.lazy
in a Next.js project, the lazy-loaded components will only be split and lazy-loaded in the client-side bundle, not during SSR.