API
QueryStateClient
The per-router cache and batched writer behind every composable.
useQueryStateClient
Returns the client of the current router, creating it on first use.
const client = useQueryStateClient()
| Method | Description |
|---|---|
get(key) | The raw value, or null when the key is absent. |
set(key, value, historyMode?) | Writes a raw value; null removes the key. Batched with every other write of the tick. |
setBatch(updates, historyMode?) | Writes several keys at once. |
subscribe(listener) | Calls listener(key, value) on every change. Returns an unsubscribe function. |
issues | A reactive ReadonlyMap<urlKey, { raw, reason, message, rule? }> of URL values that were rejected or only partly used. See Validation. |
registerQueryStateClient
Registers a client you created yourself, for example to change the default history mode. Call it before the first composable runs.
registerQueryStateClient(router, new QueryStateClient({ router, defaultHistoryMode: 'push' }))
QueryStateClient option | Type | Default |
|---|---|---|
router | Router | required |
defaultHistoryMode | 'push' | 'replace' | 'replace' |