Skip to content

serializeListViewUrlState

serializeListViewUrlState(props): URLSearchParams

Defined in: packages/core/src/collections/listView/listViewUrlState.ts:526

Serializes a (possibly partial) collection list state back into the compact-grammar URL params — the inverse of parseListViewUrlState, and also how ListViewCopyLinkButton (Step 10) builds a fully self-contained link for a local view (Step 12).

Input props.

CollectionConfig

Resolves the qf/sort/size/cols defaults (admin.view.state) and each filter leaf’s field type.

Partial<ListViewUrlState<string>>

The full state to serialize.

VexViewState<string>

The active declared (default/config) or shared view’s own saved state — omit for a local-source view (Decision 41: its full state always stays in the URL, even where it happens to coincide with the collection’s default — there’s no server-side row to fall back to for it) or when no view has resolved yet. Every field below is omitted once it equals viewState?.<field> ?? collection.admin.view.state.<field> — the EXACT inverse of resolveListViewQueryState’s own params.<field> ?? viewState?.<field> ?? collection.admin.view.state.<field> merge (Decision 9/45/48), so a written URL always round-trips to the identical resolved state instead of re-asserting a param that was already implied by the active view.

URLSearchParams

A URLSearchParams with only the non-baseline keys set — every falsy/undefined field is simply absent (Decision 9: “omitted when it’s the default”).