https://github.com/journy-io/user-agent-parser
📱 user-agent string parser
https://github.com/journy-io/user-agent-parser
client-hints device header nodejs parser user-agent
Last synced: about 1 year ago
JSON representation
📱 user-agent string parser
- Host: GitHub
- URL: https://github.com/journy-io/user-agent-parser
- Owner: journy-io
- License: mit
- Created: 2021-10-25T12:25:25.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-15T10:58:44.000Z (over 4 years ago)
- Last Synced: 2025-02-03T21:44:12.785Z (about 1 year ago)
- Topics: client-hints, device, header, nodejs, parser, user-agent
- Language: TypeScript
- Homepage:
- Size: 49.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://journy.io/?utm_source=github&utm_content=readme-user-agent-parser)
# User Agent Parser

[](https://www.npmjs.com/package/@journyio/user-agent-parser)
Inspired by [faisalman/ua-parser-js](https://github.com/faisalman/ua-parser-js).
In fact, most code is copy and 🍝. We've added TypeScript types and adopted modern syntax.
We decided to publish our own version because the package was recently [highjacked](https://github.com/faisalman/ua-parser-js/issues/536).
Why choose this package over [faisalman/ua-parser-js](https://github.com/faisalman/ua-parser-js)?
* Modern syntax
* TypeScript types
* Written in TypeScript
* Not much of a target because less popular
* Drop-in replacement
Is this package maintained?
Yes and no, we won't add new devices or browsers but will fix any bugs. We should adopt [client hints](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-client-hints-06) and use this library as a fallback.
## 💾 Installation
You can use your package manager (`npm` or `yarn`) to install:
```bash
npm install --save @journyio/user-agent-parser
```
or
```bash
yarn add @journyio/user-agent-parser
```
## 🔌 Getting started
```tsx
import { parse } from "@journyio/user-agent-parser";
const result = parse("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome Safari/537.36");
/*
{
browser: { name: 'Chrome Headless', version: undefined, major: undefined },
engine: { name: 'WebKit', version: '537.36' },
os: { name: 'Linux', version: 'x86_64' },
device: { vendor: undefined, model: undefined, type: undefined },
cpu: { architecture: 'amd64' }
}*/
```
## 💯 Tests
To run the tests:
```bash
npm run test
```
## 🔒 Security
If you discover any security related issues, please email security at journy io instead of using the issue tracker.