The easiest way to read and WRITE from query parameters in sveltekit.
### Describe the problem > Provide an api to check validity of query keys and provide defaults if invalid. For whatever reason some users try to modify our search params manually. We assume this mostly happens when a url not fully copied to the clipboard. Nonetheless you'll end up with a query that looks like `?sort=highes` for example; where the "t" is cutoff. At the moment we are the `default` parameter but that only adds a default value if the key is not present instead of checking if the value is valid it seems. We are currently checking this in our `onMount` like so; but it gets verbose when there are 15 keys to check for (search heavy data app). ```ts onMount(() => { if ($store.sort !== 'highest' ?? $store.sort !== 'recent') { $store.sort = 'highest'; } }); ``` ### Describe the proposed solution An api similar to the `default` feature that would not only check for a missing key, but check for its validity and set a default value if invalid.
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be still under discussion. The issue was opened by Rykuno and has received 2 comments.