https://github.com/hemengke1997/un-detector
A simple and zero-dependency browser, os and device detector.
https://github.com/hemengke1997/un-detector
Last synced: about 2 months ago
JSON representation
A simple and zero-dependency browser, os and device detector.
- Host: GitHub
- URL: https://github.com/hemengke1997/un-detector
- Owner: hemengke1997
- License: mit
- Created: 2023-11-15T02:39:28.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-15T02:32:50.000Z (2 months ago)
- Last Synced: 2025-04-19T03:59:02.207Z (about 2 months ago)
- Language: TypeScript
- Homepage: https://hemengke1997.github.io/un-detector/
- Size: 1.32 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# un-detector
> browser, os, device detector
[](https://www.npmjs.com/package/un-detector)
[](https://www.npmjs.com/package/un-detector)
[](https://www.npmjs.com/package/un-detector)## Install
```sh
pnpm add un-detector
```## Usage
```ts
import { detect } from 'un-detector'// client
const detected = detect(window.navigator.userAgent)// server
const detected = detect(request.headers['user-agent'])
```Then you will get device info like:
```ts
detected = {
os: {
name: 'Mac OS',
version: '10.15.7',
},
browser: {
version: '118.0.2088.61',
name: 'Edge',
majorVersion: '118',
},
device: {
model: 'Macintosh',
vendor: 'Apple',
},
is: {
mobile: false,
mobileOnly: false,
tablet: false,
mac: true,
windows: false,
iOS: false,
android: false,
winPhone: false,
linux: false,
edge: true,
chrome: false,
safari: false,
firefox: false,
opera: false,
IE: false,
chromium: false,
iPhone: false,
iPad: false,
iPod: false,
},
}```
## For ease of use
### os
```ts
import { os } from 'un-detector'console.log(os.isMac())
```### device
```ts
import { device } from 'un-detector'console.log(device.isMobile())
```### browser
```ts
import { browser } from 'un-detector'console.log(browser.isChrome())
```## Thanks
- `ua-parser-js`
- `detector-js`
- `browser-detect`
- `mobile-device-detect`