getQueryParam
Read a single query parameter value from a URL by key, returning the first match or null when the parameter is not present.
Usage
getQueryParam retrieves the value of a specific query parameter from a URL.
import { getQueryParam } from '@movk/core'
getQueryParam('https://example.com?name=John&age=30', 'name')
// 'John'
getQueryParam('https://example.com?tags=a&tags=b', 'tags')
// 'a' (returns the first value)
getQueryParam('https://example.com', 'name')
// null
API
getQueryParam(url, key)
Get the value of a specific query parameter from a URL.
Parameters
url
string required
The URL string.
key
string required
The parameter key.
Returns
returns
string | null
The parameter value, or
null if not present.Note
- If the parameter has multiple values, only the first is returned.
- Use
getQueryParamsto retrieve all values.
Changelog
No recent changes