Typed searchParams and partial updating of searchParams #11180
pyramid-scheme-ceo
started this conversation in
Proposals
Replies: 1 comment 1 reply
-
Here's a WIP implementation of the above for any feedback, have been using it already in other projects - would just be nice to have it integrated into the library itself 🙂
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is the new or updated feature that you are suggesting?
A modified version of the
useSearchParams
hook that accepts a generic type argument and a parser method argument, allowing for strongly typed search params and partially updating search params.Why should this feature be included?
The partial updating of searchParams is the main thing that's painful at the moment. The syntax of
is just a bit verbose, and also requires you to think about converting everything to strings.
I've taken inspiration from the new tanstack router project and implemented a typed approach to search params, based on having a parser (e.g. yup, zod, or your own method) and a generic type argument.
Example usage
Beta Was this translation helpful? Give feedback.
All reactions