Skip to main content
zerotal

Documentation


Documentation / @zerotal/inertia / defer

Function: defer()

defer(callback, group?, options?): DeferProp

Defined in: inertia/src/props/PropTypes.ts:305

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

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

A DeferProp wrapper.

Example

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