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
- React cache — A React function that wraps another function so repeated calls with the same arguments during one server request reuse the first result.
- request waterfall — A chain of requests where each one only starts after the previous one finished, so their waiting times add up.
- Promise — A JavaScript object that stands for a result that is not ready yet and will later either succeed with a value or fail with an error.
Taught in
- Async Data Fetching: Parallel Requests & Preloading — Next.js 15 & Modern App Router Architecture
- Image & Font Optimization: Zero Layout Shift Assets — Next.js 15 & Modern App Router Architecture