[**Documentation**](../../../README)

***

[Documentation](../../../README) / [@zerotal/inertia](../README) / defer

# Function: defer()

> **defer**(`callback`, `group?`, `options?`): [`DeferProp`](../classes/DeferProp)

Defined in: [inertia/src/props/PropTypes.ts:305](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/inertia/src/props/PropTypes.ts#L305)

Exclude this prop from the initial render and load it in an automatic follow-up
request, so the page paints immediately and heavier data streams in after. Props
sharing a `group` are fetched together in one request.

## Parameters

### callback

[`PropFactory`](../type-aliases/PropFactory)

Factory producing the prop value (may be async); runs on the deferred request.

### group?

`string` = `"default"`

Request group name; props with the same group load in one follow-up request. Default `"default"`.

### options?

`rescue: true` swallows a thrown error and reports the key in `rescuedProps` instead of failing the request.

#### rescue?

`boolean`

## Returns

[`DeferProp`](../classes/DeferProp)

A [DeferProp](../classes/DeferProp) wrapper.

## Example

```ts
return inertia('Dashboard', {
  user,
  stats:    defer(() => computeStats()),                 // group "default"
  activity: defer(() => recentActivity(), 'secondary'),  // separate request
});
```
