6

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: enter image description here

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>
    )
}
0

1 Answer 1

17

Next.js doesn't prefetch pages in development mode, prefetch is a production-only feature.

prefetch

Defaults to true. When true, next/link will prefetch the page (denoted by the href) 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.

Next.js, Components: <Link>

Try running your app in production mode instead.

npm run build && npm run start
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.