API reference

useFilters

The hook — signature, return value, and options.

useFilters(configs, options?) => UseFiltersReturn
useFilters<P>(configs, options?) => UseFiltersReturn // validate against an API type
  • configs — a map of key → f.*(). See The filter config.
  • options — per-call options (below).
  • <P> — optional API params type to validate the config against; see Typed params.

Return value

PropertyTypeDescription
paramsobjectCommitted values + pagination ({ page, per_page } by default). Fetch input & cache key. Array-shaped values are JS arrays, or joined strings under request.arrayFormat.
paramsStrstringparams as a deterministic, sorted string — a stable cache key / memo dependency.
filtersResolvedFilter[]Visible filters to render. Excludes hidden ones.
filterMapRecord<key, ResolvedFilter>Same filters keyed by config key. Includes hidden ones.
isFilteredbooleantrue when at least one visible filter differs from its default.
isDirtybooleantrue when a change hasn't reached params yet.
apply() => voidCommit all pending (debounced/manual) changes now.
cancel() => voidDiscard all pending changes, reverting to committed values.
reset() => voidClear every filter to its default, respecting each filter's commit mode (manual/debounced ones stage a draft until apply()).
instantReset() => voidClear every filter to its default, bypassing commit — one immediate batched URL write. Use for a "Clear all" button.
setFilter(key, value) => voidImperatively set one filter (resets to first page, bypasses commit).
metaFiltersMetaThe meta you passed (or {}).

Options (second argument)

These override the createFilters config for this call. Precedence: per-filter › this option › factory config › default.

OptionDefaultDescription
paginationtruefalse disables pagination; an object overrides defaultPerPage / resetPageOnFilterChange. Keys and firstPage stay factory-only.
defaultCommitfactory valueDefault commit mode for all filters this call. See Values & commits.
arraySeparatorfactory valueDelimiter for array-shaped params for this call.
history'replace''push' makes filter changes back-button navigable.
shallowtrueKeep navigation client-side (no server round-trip).
clearOnDefaulttrueDrop a param from the URL when it returns to its default.
listeners{}Side-effect hooks — onParamsChange. See Listeners.
meta{}Whole-set UI hints. See UI metadata.

The shape of each resolved filter is documented under Types.

On this page