Mirror / foldkit-mirror

URL history behavior

URL keys default to history: 'push'. A field such as free-form search text can replace the current entry instead:

ts
const Filters = Mirror.url(App, {
  name: 'filters',
  fields: [
    App.model.filter,
    App.model.page,
    App.model.q,
  ],
  keys: {
    q: { history: 'replace' },
  },
})

A key returning to its default is removed and uses replace semantics rather than creating a new history step.

Filters.href(model, { page: 2 }) applies the mirrored key changes to the current URL without touching unrelated query keys, the path, or the hash.

By default the mirror uses the query string. location: 'hash' stores its keys in the hash instead.

Outside a browser the URL store writes nothing, so server rendering is safe.