API reference
createFilters
Bind project constants and get a configured useFilters, resolveFilterParams, and helpers.
createFilters(config?) => {
useFilters,
resolveFilterParams,
defineFilters,
f,
toDateValue, fromDateValue,
toDateTimeValue, fromDateTimeValue
}Call it once per project (or per API convention) and export the result. See Sharing setup.
Top-level config
| Option | Default | Description |
|---|---|---|
defaultCommit | 'instant' | Fallback commit mode for every filter. See Values & commits. |
arraySeparator | ',' | Delimiter for array-shaped params (multiSelect, tags, ranges) in the URL. |
pagination | — | Pagination keys and defaults (below). |
date | — | Date (de)serialization (below). |
request | — | How params are shaped for a backend request (below). |
createFilters({ arraySeparator: '|' });
// tags: ['a', 'b', 'c'] ↔ ?tags=a|b|crequest
Per-API request conventions — a constant like date and pagination. Governs
the params object the hook and resolveFilterParams produce.
| Option | Default | Description |
|---|---|---|
arrayFormat | 'array' | Array-shaped params as a JS array ('array') or an arraySeparator-joined 'string'. |
Most backends expect array values as a comma-separated string. Set
request.arrayFormat: 'string' and params hands you exactly that — no mapping
before a request. Only params changes; filters / filterMap still expose
arrays for your UI, and the type of params updates to match (array kinds
become string).
const { useFilters } = createFilters({ request: { arrayFormat: 'string' } });
// tags: ['a', 'b'] → params.tags === 'a,b' (typed as string)pagination
| Option | Default | Description |
|---|---|---|
pageKey | 'page' | URL key for the page number, and its key in params. |
perPageKey | 'per_page' | URL key for the per-page count, and its key in params. |
firstPage | 1 | The number the first page counts from. 0 for a 0-indexed API. |
defaultPerPage | 10 | Per-page count assumed when the URL has none. |
resetPageOnFilterChange | true | Whether changing a filter resets the page. See Pagination. |
date
Override in inverse pairs to change how dates are stored. See Custom date formats.
| Option | Default | Description |
|---|---|---|
serialize | fixed yyyy-MM-dd | Date → stored string. |
parse | fixed yyyy-MM-dd | Stored string → Date. |
serializeDateTime | fixed yyyy-MM-ddTHH:mm:ss | Datetime counterpart of serialize. |
parseDateTime | fixed yyyy-MM-ddTHH:mm:ss | Datetime counterpart of parse. |
Returned helpers
useFilters,resolveFilterParams,defineFilters— bound to this config. See their own pages.f— the builders, re-exported for convenience.toDateValue/fromDateValueand the*DateTimepair —Date↔ stored string using this config'sdate(de)serialization.