Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link is not prefetching on hover if prefetch=false is given - as per documentation #50412

Open
1 task done
adiathasan opened this issue May 27, 2023 · 7 comments
Open
1 task done
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.

Comments

@adiathasan
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.4.0: Mon Mar  6 21:01:02 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8112
    Binaries:
      Node: 16.18.1
      npm: 8.19.2
      Yarn: 1.22.19
      pnpm: N/A
    Relevant packages:
      next: 13.4.5-canary.0
      eslint-config-next: 13.4.4
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.0.4

Which area(s) of Next.js are affected? (leave empty if unsure)

Routing (next/router, next/navigation, next/link)

Link to the code that reproduces this issue or a replay of the bug

https://github.com/adiathasan/mui-react-hook-form-plus/tree/master/next-server-components-demo

To Reproduce

  • First add a link to another page and set <Link prefetch={false} href="/your-route" /> - by default prefetch=true
import Link from 'next/link';

export default function Home() {
	return (
		<div>
			<Link prefetch={false} href='/mui'>
				MUI
			</Link>
		</div>
	);
}
  • create /your-route directories as per suggested in the app dir
image
  • terminal 👉 yarn build

  • open port http://localhost:3000

  • inspect dev tools

  • go to network tab

  • see hovering on the link that points to /your-route

Describe the Bug

It is being said that in the Link component if we set prefetch=false it will prefetch the route on hover. Below is the ss of what's coming from the description of the prop. See image v

Screenshot 2023-05-27 at 5 41 42 AM

But it's not fetching the route on hover in the background

Expected Behavior

Should fetch the page on hover if prefetch=false is set on hover in Link / next/link

Which browser are you using? (if relevant)

Chrome

How are you deploying your application? (if relevant)

Local build, next start

@adiathasan adiathasan added the bug Issue was opened via the bug report template. label May 27, 2023
@github-actions github-actions bot added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label May 27, 2023
@joacub
Copy link

joacub commented May 28, 2023

That’s is disabled for app router

if (!prefetchEnabled && isAppRouter) {
return
}

@adiathasan
Copy link
Author

That’s is disabled for app router

if (!prefetchEnabled && isAppRouter) { return }

Why is that, can anyone explain?

@deepakrh185
Copy link

To be clear that prefetching will not work in dev mode will only works in production mode @adiathasan

@adiathasan
Copy link
Author

adiathasan commented May 29, 2023

To be clear that prefetching will not work in dev mode will only works in production mode @adiathasan

Yeah, I have built the app and tried it to be clear if you see above.

@ts213
Copy link

ts213 commented Jun 27, 2023

That’s is disabled for app router
if (!prefetchEnabled && isAppRouter) { return }

Why is that, can anyone explain?

I'm also interested.

@TomJD
Copy link

TomJD commented Jan 4, 2024

Any news on this?

It is a bug, or the documentation needs updating that prefetch={false} does not actually prefetch on hover.

I am running the app in production, all other links in the viewport prefetch as expected and written in docs.

@oliviertassinari
Copy link
Contributor

I would expect that prefetch on hover continue to work. It seems another regression like #61816.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

No branches or pull requests

6 participants