DefaultPrefetchOverrides
Summary
Request and discovered-reference handling overrides for defaultPrefetch.
Signature
interface DefaultPrefetchOverrides {
fetch(url: string, init: RequestInit): Promise<Response>
processFrame(
prefetchReferences: (references?: PrefetchReferences) => Promise<void>,
context: ProcessFrameContext,
): void | Promise<void>
}
Methods
fetch(url: string, init: RequestInit): Promise<Response>
Fetches each prepared HTML request (defaults to globalThis.fetch). Capture the initiating
element from the outer prefetch handler's options. Use init.signal for queues and retries:
the caller's options signal may abort while another caller still needs the shared request.
Nested requests inherit the hook and element, but have their own URL, target header, and signal.
Parameters
url
Prepared absolute frame source URL.
init
Frame headers, X-Remix-Prefetch: true, GET method, low priority, and shared abort
signal (always supplied).
processFrame(prefetchReferences: (references?: PrefetchReferences) => Promise<void>, context: ProcessFrameContext): void | Promise<void>
Handles each parsed response. Call prefetchReferences() to prefetch discovered assets without
fetching nested sources. Passing an object overrides only the fields supplied: assets defaults
to discovered assets and frames defaults to []. Selecting frames alone retains default
assets; pass assets: [] to skip them. Returning without delegating skips Remix's work.
Responsive image and track preloads are skipped by native hints; the hook may perform and
await its own image loading or other prefetching instead.
Parameters
prefetchReferences
Starts selected default work while the hook is active.
context
Parsed HTML, source elements, frame references, and cancellation context.