Skip to content

useParams({ strict: false }) returns unparsed params #6385

Closed

Description

@foodforarabbit

Which project does this relate to?

Router

Describe the bug

"version": "1.147.3",

when using useParams with { strict: false }, we are getting unparsed values back, but they are still typed as if they were parsed.

This is caused by useMatch match.params no longer being parsed (compared to the version we upgraded from) match. _strictParams is parsed, but doesn't contain params from the child routes.

This is the patch we applied to fix the issue for us, it seems a bit blunt though but I hope it helps the team quickly narrow down the issue.

@tanstack+react-router+1.147.3.patch

Your Example Website or App

https://stackblitz.com/edit/github-3khftpeu

Steps to Reproduce the Bug or Issue

from the repro url, click the "version" link

https://stackblitz.com/edit/github-3khftpeu

Image

have a child route - createFileRoute with:

params: {
parse: (params) => ({
...params,
"version": parseInt(params["version"]),
}),
stringify: (params) => ({
...params,
"version": ${params["version"]},
}),
},

then in a parent route, do:

const { version } = useParams({ strict: false });
console.log(version); // in the ide, shows up as number | undefined but in the console, shows up as a string.

Expected behavior

I expect the runtime values of useParams to be equal to their type.

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.147.3
  • OS: macOS
  • Browser: Chrome
  • Browser Version: 143.0.7499.193
  • Bundler: vite
  • Bundler Version: 7.1.4

Additional context

No response

Activity

  1. ViewableGravy commented on Jan 19, 2026

    @ViewableGravy
    Contributor

    +1

    Everywhere that we are casting our ids from strings to numbers using zod (z.coerce.number()) is now working on first render, but on navigate will store the values as strings instead of the correct values. From what I can tell, the most nested match has the correct parsing applied, it's just the parent matches that are storing the param as a string.

    Is there a reason that the parent matches need to include the param on their object? I would only expect useParams to reference the most nested match if you use strict: false.

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

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