How to Implement useQueryState
Similar to Nuqs
#4140
Replies: 3 comments 3 replies
-
Hi, I'm the author of nuqs, FYI we have a PR to support TanStack Router: 47ng/nuqs#953. Feedback on it would be welcome! There are a few differences between nuqs & TSR:
|
Beta Was this translation helpful? Give feedback.
-
I'm also interested by this, it's not clear to me how Tanstack Router search params methods and NUQS relate/complement each other? Are they doing the same? By quickly reading the Tanstack Router doc I have the impression that the path suggested by Tanstack (eg when modifying filters on a table that we want to have reflected in the URL) is input -> change URL params -> this triggers the change of state rather than input -> triggers a change of state -> this is synchronized (without reload) in the URL are both Tanstack and Nuqs doing that? Am I misunderstanding something? Which would be the better way to do this and why? Are TSR and Nuqs complementary (as far as search-params are concerned) or serving identical purposes, and one should rather choose one or the other? |
Beta Was this translation helpful? Give feedback.
-
This is a PR to keep an eye on, which could bring a nuqs-like API built-in TSR/TSS: #4552 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on implementing a
useQueryState
hook that is similar in functionality to Nuqs but utilizing@tanstack/react-router
for handling query parameters. The implementation involves aParser
utility for parsing and stringifying different data types (string, number, boolean) and a hook that syncs state with query parameters.Here is the current implementation:
I would like feedback on the following:
Additionally, my current implementation is throwing type errors, particularly related to the parser logic and the handling of search parameters. Any insights into resolving these type issues while maintaining the intended functionality would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions