-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Which project does this relate to?
Router
Describe the bug
Hi 👋,
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="https://github.com/#/about" target="_blank">About</a>
Now the rendered <a> looks like this:
<a href="https://github.com/about" target="_blank">About</a>
This means opening the link in a new tab results in the URL:
http://localhost:5173/about
instead of the expected:
http://localhost:5173/#/about
So the hash is missing in the final URL when target="_blank" is used, breaking navigation in hash-history mode.
Expected behavior:
The <Link> should render with the hash prefix (/#/about) so that opening it in a new tab lands on the correct route in hash-history mode.
Actual behavior:
The <Link> renders as /about, causing the browser to open the wrong URL without the hash.
Your Example Website or App
https://stackblitz.com/edit/github-gsxsnwbi?file=src%2Froutes%2F__root.tsx
Steps to Reproduce the Bug or Issue
- Click on
About (target _blank). - It opens a new tab with the following URL:
<baseURL>/aboutinstead of<baseURL>/#/about
Expected behavior
The <Link> should render with the hash prefix (/#/about) so that opening it in a new tab lands on the correct route in hash-history mode.
Screenshots or Videos
No response
Platform
- Router Version: v1.131.2
- History mode:
createHashHistory() - OS: macOS/Linux
- Browser: Chrome
- Browser Version: v138
- Bundler: vite
- Bundler Version: v7.1.7
Additional context
This only happens when using target="_blank". Links without target navigate correctly within the same tab.