Skip to content

Make the default link prefetch effective on mobile (viewport, not just touchstart) #530

Description

@vivek7405

Problem

The client router's default link prefetch uses the intent strategy: it warms the next page on hover / focus / touchstart (router-client.js). On mobile this gives little to no benefit: there is no hover, and touchstart fires essentially at tap time, so the prefetch races the navigation instead of front-running it. The fast-by-default promise effectively does not hold on touch devices.

Design / approach

Research and ship a prefetch strategy that actually helps on mobile, without regressing desktop or over-fetching on metered connections:

  • Viewport / visible prefetch (Quicklink / SvelteKit hover-plus-viewport model): prefetch links as they enter the viewport, throttled and gated on navigator.connection (skip on save-data / 2g), the most reliable mobile signal.
  • Consider making the DEFAULT strategy mobile-aware (viewport on touch / no-hover, intent on pointer devices) rather than a single intent default, keeping the per-link data-prefetch override.
  • Respect prefers-reduced-data / save-data, a concurrency cap, and the existing prefetch cache + mutation eviction.
  • Keep it build-free and progressive-enhancement-safe (no behavior change with JS off).

Prior art: Quicklink, Next.js <Link prefetch>, SvelteKit data-sveltekit-preload-data="viewport", Astro prefetch viewport.

Acceptance criteria

  • Links are prefetched on mobile with a real head-start before tap (viewport or equivalent), not only at touchstart.
  • The default is mobile-effective; data-prefetch per-link overrides still work.
  • Honors save-data / reduced-data + a concurrency cap; no over-fetch.
  • Browser/e2e coverage on a touch-emulated viewport.
  • Docs (agent-docs/advanced.md client-router prefetch section) updated.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions