You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
<Link target="_blank"> broken with hash history #5209
After upgrading to the latest TanStack Router (v1.132.2), I noticed that <Link> elements using target="_blank" no longer work correctly when using hash history.
Previously, the rendered <a> looked like this:
<a href="/#/about" target="_blank">About</a>
Now the rendered <a> looks like this:
<a href="/about" target="_blank">About</a>
This means opening the link in a new tab results in the URL:
The same issue occurs on the latest version as well. But it’s not related to the target. When using HashRouter, the Link component does not add the “#” before the path.
The same issue occurs on the latest version as well. But it’s not related to the target. When using HashRouter, the Link component does not add the “#” before the path.
Yep! that is true, but regular links work fine even without the hash symbol, as the resulting URL gets it anyway.
I realize now that I misunderstood — my apologies.
I’m not very familiar with hashHistory.
Could you try applying it with the version of the PR I opened?
I realize now that I misunderstood — my apologies. I’m not very familiar with hashHistory. Could you try applying it with the version of the PR I opened?
No worries 🙂!
Your PR seems to in fact fix the issue, now all rendered <a> elements have the hash symbol (#) on their href, and work as expected regardless of whether the target property is present or not.
Activity
leesb971204 commentedon Sep 25, 2025
I think this works fine on the latest version(v1.132.6).
SavKS commentedon Sep 25, 2025
The same issue occurs on the latest version as well. But it’s not related to the target. When using HashRouter, the Link component does not add the “#” before the path.
dsiguero commentedon Sep 25, 2025
I've updated the reproduction link to use v1.132.6 and it's still not working as expected
https://stackblitz.com/edit/github-gsxsnwbi?file=src%2Froutes%2F__root.tsx
dsiguero commentedon Sep 25, 2025
Yep! that is true, but regular links work fine even without the hash symbol, as the resulting URL gets it anyway.
leesb971204 commentedon Sep 26, 2025
I realize now that I misunderstood — my apologies.
I’m not very familiar with hashHistory.
Could you try applying it with the version of the PR I opened?
dsiguero commentedon Sep 26, 2025
No worries 🙂!
Your PR seems to in fact fix the issue, now all rendered
<a>elements have the hash symbol (#) on theirhref, and work as expected regardless of whether thetargetproperty is present or not.Thank you for your work!
Dan