{"id":20235691,"url":"https://github.com/browserslist/browserslist-useragent","last_synced_at":"2025-09-07T20:12:57.702Z","repository":{"id":26116478,"uuid":"107385016","full_name":"browserslist/browserslist-useragent","owner":"browserslist","description":"🦔A utility to match a browserslist query with user agent strings","archived":false,"fork":false,"pushed_at":"2023-01-24T17:40:07.000Z","size":4430,"stargazers_count":308,"open_issues_count":14,"forks_count":30,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-30T10:08:12.938Z","etag":null,"topics":["browserlist-query","browserslist","useragent"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/browserslist.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-18T09:13:20.000Z","updated_at":"2025-03-07T07:38:10.000Z","dependencies_parsed_at":"2023-02-13T23:50:25.515Z","dependency_job_id":null,"html_url":"https://github.com/browserslist/browserslist-useragent","commit_stats":null,"previous_names":["pastelsky/browserslist-useragent"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserslist%2Fbrowserslist-useragent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserslist%2Fbrowserslist-useragent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserslist%2Fbrowserslist-useragent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserslist%2Fbrowserslist-useragent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/browserslist","download_url":"https://codeload.github.com/browserslist/browserslist-useragent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478322,"owners_count":20945266,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browserlist-query","browserslist","useragent"],"created_at":"2024-11-14T08:17:18.845Z","updated_at":"2025-04-06T12:08:23.653Z","avatar_url":"https://github.com/browserslist.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Browserslist Useragent\n\n![build](https://github.com/pastelsky/browserslist-useragent/actions/workflows/main.yml/badge.svg)\n[![npm](https://img.shields.io/npm/v/browserslist-useragent.svg)](https://www.npmjs.com/package/browserslist-useragent)\n\n\u003cimg align=\"right\" width=\"120\" height=\"120\"\n     src=\"https://cdn.rawgit.com/pastelsky/browserslist-useragent/master/logo.svg\" alt=\"Browserslist Useragent logo (original by Anton Lovchikov)\" /\u003e\n\nFind if a given user agent string satisfies a [browserslist](https://github.com/ai/browserslist) query.\n\nIt automatically reads the browserslist configuration specified in your project,\nbut you can also specify the same using the `options` parameter.\n\n**If you wish to target modern browsers, read [this](#when-querying-for-modern-browsers).**\n\n## Installation\n\nNote, `browserslist` is a peer dependency, so make sure you have that installed in your project.\n\n```bash\nnpm install browserslist-useragent\n# or \nyarn add browserslist-useragent\n```\n\n## Usage\n\n```js\nconst { matchesUA } = require('browserslist-useragent')\n\nmatchesUA(userAgentString, options)\n\n// with browserslist config inferred\nmatchesUA('Mozilla/5.0 (Windows NT 10.0; rv:54.0) Gecko/20100101 Firefox/54.0')\n//returns boolean\n\n// with explicit browserslist\nmatchesUA(\n  'Mozilla/5.0 (Windows NT 10.0; rv:54.0) Gecko/20100101 Firefox/54.0',\n  { browsers: ['Firefox \u003e 53'] }\n)\n// returns true\n```\n\n| Option              | Default Value   | Description                                                                                                                                                                                                                |\n| ------------------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| browsers            | —               | Manually provide a browserslist query (or an array of queries). Specifying this overrides the browserslist configuration specified in your project.                                                                        |\n| env                 | —               | When multiple browserslist [environments](https://github.com/ai/browserslist#environments) are specified, pick the config belonging to this environment.                                                                   |\n| path                | `process.cwd()` | Specify a folder to search for the browserslist config (if it differs from the current working directory)                                                                                                                  |\n| ignorePatch         | `true`          | Ignore differences in patch browser numbers                                                                                                                                                                                |\n| ignoreMinor         | `false`         | Ignore differences in minor browser versions                                                                                                                                                                               |\n| allowHigherVersions | `false`         | For all the browsers in the browserslist query, return a match if the user agent version is equal to or higher than the one specified in browserslist. See [why](#when-querying-for-modern-browsers) this might be useful. |\n\n## Supported browsers\n\n- Chrome (Chrome / Chromium / Yandex) as `and_chr` | `ChromeAndroid` | `Chrome`\n- Samsung Internet as `Samsung`\n- Firefox as `ff` | `and_ff` | `FirefoxAndroid` | `Firefox`\n- Safari iOS as `ios_saf` | `iOS`\n- Safari Desktop as `Safari`\n- IE as `ie` | `ie_mob`\n- Edge as `Edge`\n- Electron as `Electron`\n\nPRs to add more _browserslist supported_ browsers are welcome 👋\n\n## Notes\n\n- All browsers on iOS (Chrome, Firefox etc) use Safari's WebKit as the underlying engine, and hence will be resolved to Safari. Since `browserslist` is usually used for\n  transpiling / autoprefixing for browsers, this behaviour is what's intended in most cases, but might surprise you otherwise.\n\n- Right now, Chrome for Android and Firefox for Android are resolved to their desktop equivalents. The `caniuse` database does not currently store historical data for these browsers separately (except the last version) See [#156](https://github.com/ai/browserslist/issues/156). However,\n  safari for iOS and desktop can be matched separately, since this data is available for both.\n\n## When querying for modern browsers\n\n- It is a good idea to update this package often so that browser definitions are upto date.\n- It is also a good idea to add `unreleased versions` to your browserslist query, and set `ignoreMinor` and `ignorePatch` to true so that alpha / beta / canary versions of browsers are matched.\n- In case you're unable to keep this package up-to-date, you can set the `allowHigherVersions` to `true`. For all the browsers specified in your browserslist query, this will return a match if the user agent version is equal to or higher than those specified in your browserslist query. Use this with care though, since it's a wildcard, and only lightly tested.\n\n## Further reads\n\n- [Smart Bundling: Shipping legacy code to only legacy browsers](https://www.smashingmagazine.com/2018/10/smart-bundling-legacy-code-browsers/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserslist%2Fbrowserslist-useragent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrowserslist%2Fbrowserslist-useragent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserslist%2Fbrowserslist-useragent/lists"}