When using next/router's router.push() (and presumably other methods) with a hash parameter, the hash does not properly appear or the url ends up improperly interpolated (in the case of dynamic routes).
Steps to reproduce the behavior, please provide code snippets or a repository:
Static page with hash (good) buttonDynamic page with hash (bad) buttonDynamic page with hash (bad) button againDynamic page with hash (bad) linkThe URL should have the hash properly appended the first time the dynamic page button is clicked, and the URL should stay properly interpolated with dynamic route params the second time the dynamic page button is clicked.
If applicable, add screenshots to help explain your problem.

Add any other context about the problem here.
I'm experiencing a similar issue with hashes and dynamic routes. In my case, I have nested dynamic routes for /[category]/[article] and trying to route to just a category with a hash, ie. /some-category-slug#hash throws an error stating the following:
Error: The provided `as` value (/some-category-slug) is incompatible with the `href` value (/[category]/[article]). Read more: https://err.sh/vercel/next.js/incompatible-href-as
As you can see, it incorrectly tries to match the nested article route and not the top-level category route.
I am routing using the next/link Link component:
<Link
href={{
pathname: '/[category]',
query: { category: 'some-category-slug' },
hash: 'hash',
}}
>
<a>Link</a>
</Link>
or using a href string:
<Link href="some-category-slug#hash">
<a>Link</a>
</Link>
More interestingly is that this only happens when running Next.js in dev-mode. In production-mode, (yarn build && yarn start) it works as expected.
It is the same for Next.js v9 and the new v10.
I have just started working with next.js and with next/link.
I don't know if I'm having the problem or it is with the hashes not working.
<li className="nav-item">
<Link scroll={false} href="/index#out">
<a className="nav-link">Stories</a>
</Link>
</li>
Should go to my index page and scroll down to the "out" in the id or name (have both).
The problem is that this is part of DefaultStyle.js which is invoked by
Most helpful comment
I'm experiencing a similar issue with hashes and dynamic routes. In my case, I have nested dynamic routes for
/[category]/[article]and trying to route to just a category with a hash, ie./some-category-slug#hashthrows an error stating the following:Error: The provided `as` value (/some-category-slug) is incompatible with the `href` value (/[category]/[article]). Read more: https://err.sh/vercel/next.js/incompatible-href-asAs you can see, it incorrectly tries to match the nested article route and not the top-level category route.
I am routing using the
next/linkLinkcomponent:or using a
hrefstring:More interestingly is that this only happens when running Next.js in dev-mode. In production-mode, (
yarn build && yarn start) it works as expected.It is the same for Next.js v9 and the new v10.