> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# Function: lazy()

> **lazy**\<`T` _extends_ `ComponentType`\<`any`>>(`load`: () => `Promise`\<\{ `default`: `T`; }>): `LazyExoticComponent`\<`T`>

Lets you defer loading a component’s code until it is rendered for the first time.

## Type Parameters

| Type Parameter                        |
| ------------------------------------- |
| `T` _extends_ `ComponentType`\<`any`> |

## Parameters

| Parameter | Type                                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| --------- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `load`    | () => `Promise`\<\{ `default`: `T`; }> | A function that returns a `Promise` or another thenable (a `Promise`-like object with a then method). React will not call `load` until the first time you attempt to render the returned component. After React first calls load, it will wait for it to resolve, and then render the resolved value’s `.default` as a React component. Both the returned `Promise` and the `Promise`’s resolved value will be cached, so React will not call load more than once. If the `Promise` rejects, React will throw the rejection reason for the nearest Error Boundary to handle. |

## Returns

`LazyExoticComponent`\<`T`>

## See

[React Docs](https://react.dev/reference/react/lazy)

## Example

```tsx
import { lazy } from 'react';

const MarkdownPreview = lazy(() => import('./MarkdownPreview.js'));
```
