Next.js Discord

Discord Forum

Bug with anchor links in Next.js 14

Unanswered
Bee posted this in #help-forum
Open in Discord
BeeOP
Hi there!

I’m facing an issue with anchor links in Next.js:

If I navigate to an anchor link on the same page, everything works perfectly.
But if I navigate from a different page, it only loads the target page without scrolling to the specific element.
I also noticed that when using <Link>, the issue happens even on desktop. Replacing it with a regular <a> partially fixes the issue, but it still doesn’t work on some mobile devices.


<li>
<a href={/${lange}#payCont} itemProp="url">
<span itemProp="name">{lib.aboutUs}</span>
</a>
</li>


Has anyone encountered this? I’d really appreciate any advice or tips on how to fix it!

web link - https://europasar.vercel.app/en

0 Replies