Public
Like
nuqs-demo
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v9View latest version
A super simple demonstration of nuqs - a library for managing URL search parameters as React state.
- A text input that syncs with the URL search parameter
name - Real-time URL updates as you type
- State persistence on page refresh
- Basic
useQueryStatehook usage
useQueryState('name')creates a state variable that syncs with?name=valuein the URL- The app is wrapped in
NuqsAdapterto enable the functionality - Setting the state to
nullremoves the parameter from the URL
- Type in the input field and watch the URL change
- Refresh the page - your input is preserved
- Manually edit the URL parameter and see the input update
