Fragment identifier not working on my Next.js app

I have a link in my Next.js app that looks like this:

<a href="/#projects">Projects</a>

This link is obviously supposed to navigate to the element with id projects, and it woks locally, on Vercel, and on Heroku, but for some reason on Netlify, it just reloads the page.

When trying to open it in a new tab, it works, but no on the same tab.

Hi @hewar-saber , thanks for the post and Welcome to the Netlify Support Forums.

If you have not tried using the Next.js Link component already, kindly use it to see if it resolves the problem.

import Link from 'next/link'

// ...
<Link href="/#projects">Projects</Link>
// ...

Kindly check the Official Next.js Documentation page for more details.

Let me know the outcome.


I figured out this behavior was caused by a bug in my code, I disabled JavaScript and it worked fine. I will try to figure it out.

Thank you though!

1 Like

Hiya, thanks for writing back in about your solution! Glad you were able to resolve this. :+1:t6:

1 Like