Skip to content

getParam

getParam(url, param): string | null

Defined in: search-params.ts:12

The value of query parameter param in url, null when the URL has a query but not that parameter, and "" when it has no query at all.

string

string

string | null

import { getParam } from "@theholocron/uri-utils";
getParam("https://example.com?page=2&limit=10", "page"); // "2"
getParam("https://example.com?page=2&limit=10", "sort"); // null
getParam("https://example.com", "page"); // ""