Skip to content

@gluonjs/core / packages/router/src / parseQuery

Function: parseQuery() ​

parseQuery(search): LocationQuery

Parameters ​

string

Returns ​

LocationQuery

Example ​

Decode a URL search string into normalized immutable values, preserving repeated keys and keys without an equals sign:

ts
import {
  parseQuery,
  stringifyQuery,
  type LocationQuery,
  type LocationQueryPrimitive,
  type LocationQueryRaw,
  type LocationQueryValue,
} from '@gluonjs/router';

const sort: LocationQueryPrimitive = 'price-asc';
const categories: LocationQueryValue = ['lighting', 'seating'];
const raw = { sort, category: categories, inStock: true } satisfies LocationQueryRaw;
const search = stringifyQuery(raw);
const query: LocationQuery = parseQuery(search);
console.log(search, query.category);

Version-matched documentation. Examples are checked against the public package contracts.