Replies: 1 comment
-
Duplicate of #12375 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Introduce a prefetch option in RouteObject so that React Router can preload code or data for likely next routes. This improves navigation speed and keeps prefetch logic close to routing.
API
interface RouteObject {
path?: string;
element?: React.ReactNode;
children?: RouteObject[];
prefetch?: Array<() => Promise>;
}
Runs on mount by default (future: hover, viewport, idle policies)
Executes once per session; errors are non‑blocking
Example
Benefits
Faster perceived navigation
Centralized, standardized prefetching
Backward compatible (optional field)
Notes
Over‑prefetch may waste bandwidth → allow global limits/policies
Compatible with Suspense (dynamic imports resolve instantly after prefetch)
Ask: Add prefetch support in core to simplify performance optimization.
Beta Was this translation helpful? Give feedback.
All reactions