-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Which project does this relate to?
Router
Describe the bug
The problem is that Router interprets Strings that look like a Number as Numbers at some point.
This behavior introduces 2 major issues:
- Numeric strings wrapped with double quotes — they shouldn't.
- If the numbers (that I expect to read as strings in my schema) are too large — they are modified.
So when I will pass &numericString=723421968459640832 to URL it will be transformed twice:
723421968459640832became723421968459640800(since it's too big for Number)- And it will be wrapped with
""and became&numericString="723421968459640800"
And the code is here — https://github.com/isnifer/tanstack-issue-537/blob/master/src/routes/issue.tsx
And yes I see your response here #989 (comment) to transform big numbers to add double quotes, but c'mon, it should not be double quotes for numeric strings at all.
UPD: I've added a second page with the same Zod schema where I need to parse z.coerce.string() value from params – and it just works. No double quotes, no transformation URL => number => string. And added example with EXPECTED issue of casting from string to number (z.coerce.number()) to show the difference.
Your Example Website or App
https://tsr-issue-537.netlify.app
Steps to Reproduce the Bug or Issue
- Go to site
- Click to link on top
- Watch to search parameters in URL
- Read steps on that page
Expected behavior
As a user, I expected — numeric parameters even expected as strings would NOT be wrapped with double quotes and would NOT parsed after page transition. Since HUGE numbers will change their values to unpredictable like 723421968459640832 became 723421968459640800 in the provided example.
Screenshots or Videos
I recorded an example and made it slow to 0.25x, you can see how the Router transforms the URL.
You can find out on the 00:08 how it makes these 2 changes.
screen-recording-2025-12-06-at-043738_gL4Be7DF.mov
Platform
- Router / Start Version: 1.132.0
- OS: macOS
- Browser: Chrome
- Browser Version: 144.0.7559.4 beta (arm64)
- Bundler: vite
- Bundler Version: ^7.1.7
Additional context
No response