Give your URL
a type system.
Turn query strings into state you can trust. Define your model once. Decode, recover, and encode wherever your app runs.
pnpm add @queryweave/core?search=vue&page=abc
defineQueryModel()decode · validate · recover{
search: "vue",
page: 1
}string | undefined · numberpage=abc is invalid. Using 1.- One definition
- Typed recovery
- Canonical links
- Adapter-driven navigation
One definition.
No drift.
Your URL is part of your application’s state. Give it the same care as the rest of your types.
Meet the query modelimport { defineQueryModel, param } from "@queryweave/core";
const model = defineQueryModel({
search: param.text().optional(),
page: param.integer({ min: 1 }).default(1),
});
const result = model.decode("?search=vue&page=abc");result.ok === trueRecovered, with an issue.- Decode
- Query strings become typed values.
"2"becomes the number2. - Recover
page=abcfalls back to1. The result includes an issue explaining why.- Encode
- Defaults stay out of the URL. The recovered state becomes
?search=vue.
Go on. Break the query.
Change a value. Try a broken link. See exactly what the model keeps, recovers, and writes back.
This model accepts search and page. A page must be an integer of at least 1.
Typed state
Recovered{
search: "vue",
page: 1
}Types from your model. Ready for your application.
1 issue reported
page · invalid"page" must be an integer.
All values match the model.
Canonical query
?search=vueDefaults are omitted. Only this model’s keys are encoded.
Running on @queryweave/core Same model. Actual results.
State moves.
The model stays.
Read a URL, change a value, write a link. The same definition keeps every step connected.
- 01
Decode
?search=vue&page=abcRecover the invalid page to its default.
{ search: "vue", page: 1 } - 02
Update
await runtime.update({ page: 2 })Apply a typed change through the runtime.
{ search: "vue", page: 2 } - 03
Encode
?search=vue&page=2The adapter handles navigation. The model handles the values.
Explore the runtime
One model.
Your environment.
Start with the core. Add the packages your application needs. Each integration shares the same model semantics.
Explore the architectureMake your next link
a little smarter.
Start with a model. Let the URL carry the state.
Experimental beta · v0.1.0-beta.5QueryWeave is pre-1.0 and is not production ready. Its API may change between minor versions. Read the stability policy.