Skip to content

[bug] Tanstack Router: parseAsTimestamp parses defalt value as 1970-01-01T00:00:02.025Z when reloaded or opened with searchParams #1177

@mdhruvil

Description

@mdhruvil

Context

What's your version of nuqs?

"nuqs": "^2.7.2"

What framework are you using?

  • ✅ Other (Tanstack Router)

Which version of your framework are you using?

"@tanstack/react-router": "^1.132.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"

Description

BUG: When query states is changed to ?from=1760207400000&to=1760812199999 and I reload the page or open the same URL in different tab, it fails to parse the value and changes the url to ?from="1970-01-01T00%3A00%3A02.025Z"&to="1970-01-01T00%3A00%3A02.025Z"

EXPECTED: URL to be same and parse the timestamps correctly.

However this only happens when I add validateSearch in route definition

export const Route = createFileRoute("/")({
  component: App,
  // THE BUG ONLY HAPPENS WHEN USING validateSearch IF I REMOVE `validateSearch` IT WORKS AS EXPECTED
  validateSearch: createStandardSchemaV1(searchParams, {
    partialOutput: true,
  }),
});

Reproduction

Deployed Version: https://nuqs-repro.pages.dev/
GitHub Repo: https://github.com/mdhruvil/nuqs-repro

  • Visit "/"
  • Current Week is selected by default, see URL and values displayed on page
  • Click on "Set to Previous Week"
  • It changes url to select previous week (works as expected)
  • Refresh the page or copy url and open in new tab
  • It changes url to ?from="1970-01-01T00%3A00%3A02.025Z"&to="1970-01-01T00%3A00%3A02.025Z" instead of parsing the actual timestamp values

Metadata

Metadata

Assignees

No one assigned

    Labels

    adapters/tanstack-routerUses the TanStack Router adapterbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions