Easily put frontend-only search params (state) in url hash but retain validation #5153
devinrhode2
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Imagine you have an api endpoint that gets you a list of 500 report names, which the user can search/filter through, and then click to open.
While we will have a fast endpoint to get the full list of 500 report names, the user is only going to care about a subset of these. So, we'll have a sort of filter/search functionality, but it's only going to operate on the frontend. We could just useState, but I want to put things in the url for transparency and share-ability. So yes, I can just manually read/write some hash parameters to location.hash, and also, I can add some zod schemas on top of that - but I do feel this fits more cleanly into tanstack's area of expertise/concern, it would be a nice feature for others to make use of.
One personal motivation here, is that I want to keep our openapi/schema connecting frontend to backend as clean as possible; I could just use search parameters, but if they aren't going to be used by the backend, if they shouldn't be used by the backend, they shouldn't be in the openapi schema.
Beta Was this translation helpful? Give feedback.
All reactions