WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Numeric search parameters wrongly parsed and wrapped with quotes #6044

@isnifer

Description

@isnifer

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:

  1. Numeric strings wrapped with double quotes — they shouldn't.
  2. 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:

  1. 723421968459640832 became 723421968459640800 (since it's too big for Number)
  2. 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

  1. Go to site
  2. Click to link on top
  3. Watch to search parameters in URL
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions