# ua-query

> Lazy user agent string checker for connect compatible requests

Latest version **2.0.1** (published 2025-06-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install ua-query
pnpm add ua-query
yarn add ua-query
bun add ua-query
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2025-06-06 |
| First published | 2016-12-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Damian Krzeminski |
| Maintainers | pirxpilot |
| Keywords | ua-query, user-agent, request, connect |

## Links

- npm: https://www.npmjs.com/package/ua-query
- Repository: https://github.com/pirxpilot/ua-query
- Homepage: https://github.com/pirxpilot/ua-query#readme
- Issues: https://github.com/pirxpilot/ua-query/issues
- npm.io page: https://npm.io/package/ua-query

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2025-06-06
- 2.0.0 — 2024-03-29
- 1.3.2 — 2021-12-05
- 1.3.1 — 2020-03-12
- 1.3.0 — 2018-02-15
- 1.2.1 — 2017-06-06
- 1.2.0 — 2017-06-04
- 1.1.0 — 2017-05-21
- 1.0.2 — 2017-05-21
- 1.0.1 — 2017-02-19
- 1.0.0 — 2016-12-29
- 0.0.0 — 2016-12-29

## README

[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]

# ua-query

Lazy user agent string checker for connect compatible requests

## Install

```sh
$ npm install --save ua-query
```

## Usage

```js
var ua = require('ua-query');

function middleware(req, res, next) {
  if (ua.isChrome(req, 45) || ua.isFirefox(req, 40)) {
    res.locals.polyfills = false;
  }
}
```

## API

`ua-query` functions take request as the first parameter and optionally version number as the second.

browsers:
- `isChrome(req[, version])`
- `isFirefox(req[, version])`
- `isSafari(req[, version])`
- `isIE(req[, version])`
- `isEdge(req[, version])`
- `isBot(req[, version])` - a few strange bots


- `isOld(browser, version)` - true if browser type matches but the version is older than specified version

OS:
- `isWindowsXP(req)`


## In-browser usage

When used in the browser `ua-query` will check self.navigator.userAgent. Browser-side API is similar to
server-side API but it skips `req` parameter.

```js
var ua = require('ua-query');

function isModern(req, res, next) {
  return ua.isChrome(45) || ua.isFirefox(40);
}
```


## License

MIT © [Damian Krzeminski](https://pirxpilot.me)

[npm-image]: https://img.shields.io/npm/v/ua-query
[npm-url]: https://npmjs.org/package/ua-query

[build-url]: https://github.com/pirxpilot/ua-query/actions/workflows/check.yaml
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/ua-query/check.yaml?branch=main

---
_Source: https://npm.io/package/ua-query · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
