---
title: "hasQueryParam"
description: "Check whether a URL contains a query parameter with the given key, returning a boolean so you can branch on the presence of a flag."
canonical_url: "https://core.mhaibaraai.cn/en/docs/utilities/url/has-query-param"
---
# hasQueryParam

> Check whether a URL contains a query parameter with the given key, returning a boolean so you can branch on the presence of a flag.

## Usage

`hasQueryParam` checks whether a URL contains a specific query parameter.

```ts
import { hasQueryParam } from '@movk/core'

hasQueryParam('https://example.com?page=1', 'page') // true
hasQueryParam('https://example.com?page=1', 'sort') // false
hasQueryParam('https://example.com?flag', 'flag') // true (valueless parameter)
```

## API

### `hasQueryParam(url, key)`

Check whether a URL contains a specific query parameter.

### Parameters

**url** (`string`) *required*: The URL string.

**key** (`string`) *required*: The parameter key.

### Returns

**returns** (`boolean`): Whether the parameter is present.

## Changelog

See commit history for [src/utilities/url/query.ts](https://github.com/mhaibaraai/movk-core/commits/main/src/utilities/url/query.ts).

---

- [GitHub](https://github.com/mhaibaraai/movk-core/blob/main/src/utilities/url/query.ts)


## Sitemap

See the full [sitemap](https://core.mhaibaraai.cn/sitemap.md) for all pages.
