API

useQueryStates

Bind a schema of keys to one writable object, with cross-field rules, written in one navigation.

Hover the name for its full signature.

import { 
useQueryStates
} from '@chronicstone/vue-route-query'

Options

OptionTypeDescription
schemaRecord<string, codec | dynamicQueryState>One entry per property of the value.
prefixstringPrepended to every key as prefix.key.
urlKeys{ [property]?: string }URL keys that differ from the property names.
historyMode'push' | 'replace'History mode for writes from this group. A codec's own historyMode wins for its key.
rulesRecord<string, rule>Cross-field rules, keyed by name.

Rules

FieldTypeDescription
keys(keyof schema)[]The keys the rule reads. The rule is skipped while any of them is undefined.
check(values) => booleanGets the named keys, typed and defined. Return false to reject.
rejectkeys from keysKeys that fall back to their defaults when check fails. Must be among keys.
messagestringShown in issues and in the development warning.

Rules run in declaration order when the URL is read. Writes from your code are kept as they are.

Returns

WritableComputedRef<{ [K in keyof schema]: value of K }>. Assign a whole new object to write. Every key of the group goes to the URL in one navigation.

Copyright © 2026 Cyprien Thao. Released under the MIT License.