Performance: Prefetching links
Prefetching links improves page load speed by loading resources before the user clicks, reducing wait time for navigation.
import { Link } from '@remix-run/react'; export default function Nav() { return <Link to="/about" prefetch="intent">About</Link>; }
import { Link } from '@remix-run/react'; export default function Nav() { return <Link to="/about" prefetch="all">About</Link>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Prefetch all links immediately | Minimal | 0 | Low but network heavy | [X] Bad |
| Prefetch on user intent (hover/focus) | Minimal | 0 | Low and network efficient | [OK] Good |
prefetch attribute do when used on a Remix Link component?prefetch attribute does on a LinkLink component?<Link to='/dashboard' prefetch='render'>Dashboard</Link>
Link component that tries to prefetch on hover:<Link to='/profile' prefetch='hovering'>Profile</Link>
Pass the test and this pattern moves unknown