mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
ec1a44d0f1
With the latest GA changes, when using Cache Components with Partial
Prefetching:
> prefetch={true} turns on prefetching
These changes try to align around that idea.
- runtime prefetching guide is now about optimizing
- various changes in prose across docs
- even fix an error page for pages router, which had a broad title
---------
Co-authored-by: Aurora Scharff <aurora.sofie@gmail.com>
34 lines
1.0 KiB
Plaintext
34 lines
1.0 KiB
Plaintext
---
|
|
title: '`prefetch={true}` is deprecated (Pages Router)'
|
|
---
|
|
|
|
## Why This Error Occurred
|
|
|
|
This message is about the Pages Router [`<Link>`](/docs/pages/api-reference/components/link) component from `next/link`.
|
|
|
|
Since [Next.js 9](/blog/next-9#prefetching-in-viewport-links), 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>
|
|
```
|