Skip to content

Function: getUrlParam() ​

getUrlParam<TName, TAsArray, TResult>(name?, url?, asArray?): TResult

Defined in: packages/core/src/str/getUrlParam.ts:16

Read parameters of a given URL

Type Parameters ​

TName ​

TName extends string | undefined

TAsArray ​

TAsArray extends true | string[] | undefined

TResult ​

TResult = TName extends undefined ? Record<string, string> : string | string[]

Parameters ​

name? ​

TName

(optional) name of a specific parameter to get value of. If not provided, will return an object containing all the URL parameters with respective values.

url? ​

string | URL

(optional) default: window.location.href

asArray? ​

TAsArray

(optional) parameter names that should be returned as Array. By default if a parameter contains multiple values it will be returned as unique Array.

Returns ​

TResult