Skip to content

hook syncfilterstosearchparams

Paulo Gomes da Cruz Junior edited this page Oct 23, 2026 · 4 revisions

useSyncFiltersToSearchParams Hook (Removed)

Status

Removed 2026-10-22 in the file-based router migration (PR #1447). The hook no longer exists in the codebase and must not be imported or imitated.

What it did

useSyncFiltersToSearchParams managed bidirectional synchronization between a filter state object and URL search parameters: on mount it hydrated filter state from the URL, and on every filter change it serialized state back into URL params (with { replace: true }), optionally through per-key transforms.

Why it was removed

The hook merged from main shortly before the routing cutover, and the migration made it redundant rather than migrating it:

  • The /search route now owns its filter state through TanStack Router validateSearch: validateWasteSearch — the URL is the single source of truth, validated by the Zod schema in frontend/src/routing/searchParams.ts.
  • Reading filters is useSearch on the route; writing filters is a typed navigation that updates search params. There is no second React state to keep in sync, so a bidirectional sync hook has nothing to do.
  • Per-key transforms are unnecessary because the schema is the single place that decides how each parameter is typed, and the router-level searchParamCodec writes plain, human-readable URLs (strings unquoted, arrays comma-joined, booleans true/false).

Maintaining both mechanisms would mean two definitions of "what the URL means" — the hook was deleted in the same change instead.

Where the behavior lives now

Old hook responsibility New home
Hydrate filters from the URL /search route validateSearch + useWasteSearchFilters reading useSearch
Serialize filters to the URL Typed navigation writes; searchParamCodec in createAppRouter handles encoding
Lenient parsing (bad values degrade) Zod schema .catch(undefined) per key — a malformed URL never fails the route
Legacy URL compatibility parseSearch JSON-decodes quoted/legacy values where needed

Further reading

  • Routing — search state, the codec contract, and the request flow
  • [File-Based Router Migration 20261022](File-Based Router Migration 20261022) — the change record with full reasoning

Waste Plus Wiki

Home

Architecture

Codes

Decisions

Knowledge Base

Development

Changes

Clone this wiki locally