Skip to content

Conversation

@mehdibha
Copy link
Contributor

@mehdibha mehdibha commented Dec 22, 2025

The current Tanstack Start routing setup doesn't handle external links properly. When passing a string href (e.g., <MenuItem href="https://github.com">), the router's navigate and buildLocation methods fail with:

String.prototype.search called on null or undefined

Added type guards to handle string hrefs separately:

<RouterProvider
  navigate={(href, opts) => {
    if (typeof href === "string") return;
    router.navigate({ ...href, ...opts });
  }}
  useHref={(href) => {
    if (typeof href === "string") return href;
    return router.buildLocation(href).href;
  }}
>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant