Mirror / foldkit-mirror
URL history behavior
URL keys default to history: 'push'. Set history: 'replace' on fast-changing keys such as search text so typing replaces the current history entry instead of flooding the Back button:
ts
const Filters = Mirror.url(App, {
name: 'filters',
fields: [
App.model.filter,
App.model.page,
App.model.q,
],
keys: {
q: { history: 'replace' },
},
})When a key returns to its default value, it is removed from the URL using replace. Call Filters.href(model, { page: 2 }) to build a link with updated keys while keeping unrelated query parameters, the path, and the hash intact. Set location: 'hash' to store keys in the hash instead of the query string. Outside a browser, the URL store skips writes so server rendering stays safe.