Skip to content

fix(docs): update tanstack start routing setup#9396

Merged
snowystinger merged 6 commits intoadobe:mainfrom
mehdibha:patch-3
Jan 7, 2026
Merged

fix(docs): update tanstack start routing setup#9396
snowystinger merged 6 commits intoadobe:mainfrom
mehdibha:patch-3

Conversation

@mehdibha
Copy link
Copy Markdown
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;
  }}
>

stunaz
stunaz previously requested changes Dec 31, 2025
Comment thread packages/dev/s2-docs/src/routers.mdx Outdated
useHref={href => router.buildLocation(href).href}>
navigate={(href, opts) => {
if (typeof href === "string") return;
router.navigate({ ...href, ...opts });
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return router.navigate({ ...href, ...opts });

Comment thread packages/dev/s2-docs/src/routers.mdx Outdated
Comment thread packages/dev/s2-docs/src/routers.mdx Outdated
@snowystinger snowystinger added this pull request to the merge queue Jan 7, 2026
Merged via the queue into adobe:main with commit 953488a Jan 7, 2026
31 checks passed
navigate: (href, opts) => router.navigate({...href, ...opts}),
useHref: href => router.buildLocation(href).href
navigate: (href, opts) => {
if (typeof href === "string") return;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this case actually occur? Wouldn't that mean nothing happens when you click the link?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case, it behaves like a normal <a>.

@yihuiliao yihuiliao added the documentation Improvements or additions to documentation label Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants