Skip to content

remix/component · Function

View Source

defaultPrefetch

Summary

Fetches and parses frame HTML, then prefetches discovered assets.

Prepared HTML requests use low priority and send X-Remix-Prefetch: true. Overrides receive the prepared GET request and the inert parsed fragment. Native asset hints never run scripts or apply styles. Pending requests are shared by source and target; the first caller supplies the overrides. Nested sources are exposed to the processFrame hook and fetched only when explicitly selected. Completed responses are discarded. Failures and cancellation finish without affecting navigation, and custom work must honor the provided signal.

Signature

function defaultPrefetch(
  src: string,
  options: PrefetchFrameOptions,
  overrides: DefaultPrefetchOverrides,
): Promise<void>

Parameters

src

Same-origin frame source, resolved against the document base URL.

options

Destination frame, cancellation signal, and triggering element.

overrides

HTML fetch implementation and post-parse reference handling.

Returns

Completes after the hook and delegated work finish, or when cancelled.