T
TanStack5mo ago
quickest-silver

Link `to` urls can't be external but `href` still requires `to`

Using the start-bare example I am not able to use <Link to="http://...">External</Link because it matches no routes but using href instead I see a complaint about missing to. Did this change and is there a proper way to link to external urls?
6 Replies
flat-fuchsia
flat-fuchsia5mo ago
link is not meant for external links use an <a> for that
quickest-silver
quickest-silverOP5mo ago
ah ok 👍
vicious-gold
vicious-gold4mo ago
@Manuel Schiller But the Link component explicitly checks for external links, it's just not accepting them on a type-level: https://github.com/TanStack/router/blob/ef74fc661bb82cbc415fcc6645cffcaec9b3b8b7/packages/react-router/src/link.tsx#L88-L94 This would be extremely helpful for custom link components, to have the same styling for internal and external links.
GitHub
router/packages/react-router/src/link.tsx at ef74fc661bb82cbc415fcc...
🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering. - TanStack/router
flat-fuchsia
flat-fuchsia4mo ago
i agree @Chris Horobin was looking into this do we have a GitHub issue for this already? if not please create one so we can properly track this
vicious-gold
vicious-gold4mo ago
I created it: https://github.com/TanStack/router/issues/4901 (I had to use the bug template because FR just links to GitHub discussions)
GitHub
Link should accept external links · Issue #4901 · TanStack/router
Which project does this relate to? Router Describe the bug The Link component, custom link components created with createLink() and possibly linkOptions() only accept internal links but should acce...
conscious-sapphire
conscious-sapphire3mo ago
Running into this issue today! Is there a workaround to allow TanStack's Link to accept internal and external links?

Did you find this page helpful?