What is React.lazy and Suspense? How does lazy loading work in React?
Learn how to optimize React apps with code-splitting using React.lazy and Suspense.
advancedPerformance optimizationreact lazysuspensecode splittinglazy loading
Published: 10/26/2025
Updated: 10/26/2025
React.lazy enables code-splitting, allowing components to load only when needed.
⚙️ Example
const Profile = React.lazy(() => import('./Profile'));
function App() {
return (
<Suspense fallback={<p>Loading...</p>}>
<Profile />
</Suspense>
);
}
âś… Benefits:
- Reduces initial bundle size.
- Improves load times.
- Perfect for large applications with multiple routes.
⚠️ Use Suspense to handle component loading states gracefully.
Stay Updated
Get the latest frontend challenges, interview questions and tutorials delivered to your inbox.