TanStackT
TanStack4mo ago
7 replies
dramatic-maroon

Removing search params when leaving page

Is there a way to remove a search parameter when navigating away from a page?
I have a page that accepts the search parameter sortBy=something. When the user navigates to another page that also supports a sortBy parameter (but with different valid values), I want to ensure that the sortBy parameter is removed so it can fall back to the default value on the new page.

I tried setting strict = true in the router configuration, but since both pages accept sortBy, the parameter isn’t removed.
Was this page helpful?