Back to Next Js

`prefetch={true}` is deprecated (Pages Router)

errors/pages-router-prefetch-true-deprecated.mdx

16.3.3981 B
Original Source

Why This Error Occurred

This message is about the Pages Router <Link> component from next/link.

Since Next.js 9, the Pages Router <Link> prefetches automatically: as a link enters the viewport, Next.js prefetches the route's assets in the background. Passing prefetch={true} asks for behavior that is already the default, so the prop is redundant and deprecated.

Prefetch requests are low priority and yield to fetch() and XHR requests. Next.js also skips them when the visitor has data-saver enabled.

Possible Ways to Fix It

Remove the redundant prefetch prop, since automatic prefetching is already the default:

jsx
// Before
<Link href="/about" prefetch={true}>
  About
</Link>

// After
<Link href="/about">About</Link>

To turn prefetching off for a specific link, set prefetch={false}:

jsx
<Link href="/about" prefetch={false}>
  About
</Link>