API
useQueryState
Bind one query-string key to a writable computed ref, typed by its codec.
Hover the name for its full signature.
import { useQueryState } from '@chronicstone/vue-route-query'
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The query-string key to read and write. |
codec | a codec | Format, rules, default, and write options. See Codecs. |
Returns
WritableComputedRef<T>, where T is the codec's value type, without undefined when the codec has a default.
- Reading returns the parsed value, or the default when the key is missing or rejected.
- Assigning normalizes the value through the codec, updates every ref bound to the same key at once, and writes the URL at the end of the tick.
Lifecycle
Call it inside setup, or anywhere useRouter() works. The subscription is removed when the surrounding effect scope is disposed, usually when the component unmounts.