preloading pattern

Starting a data request early, before the component that needs it renders, so the result is ready or nearly ready when it is used.

In more detail

A preload() function calls a cached data function without awaiting it. Because React cache deduplicates calls, the component that later awaits the same function gets the already-running Promise instead of starting a new request.

Example

export const preload = (id: string) => { void getItem(id); };

Related terms

Taught in

References