I read many blogs everyone mentions that Next.js prefetches the Link but it was not working for me.
Here is my chrome network tab:
that is my code that I tried:
import Link from 'next/link'
export default function Home() {
return (
<div >
<Link href="/home">
<a>Home</a>
</Link>
<Link href="/About/about">
<a>About</a>
</Link>
</div>
)
}
Next.js doesn't prefetch pages in development mode, prefetch is a production-only feature.
prefetch
Defaults to
true
. Whentrue
,next/link
will prefetch the page (denoted by thehref
) in the background. This is useful for improving the performance of client-side navigations. Any<Link />
in the viewport (initially or through scroll) will be preloaded.Prefetch can be disabled by passing
prefetch={false}
. Prefetching is only enabled in production.
Try running your app in production mode instead.
npm run build && npm run start