Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timvanscherpenzeel/detect-ua
A small user-agent detection library (1 kB).
https://github.com/timvanscherpenzeel/detect-ua
browser deskop detection device efficient lightweight mobile small tablet user-agent
Last synced: 4 months ago
JSON representation
A small user-agent detection library (1 kB).
- Host: GitHub
- URL: https://github.com/timvanscherpenzeel/detect-ua
- Owner: TimvanScherpenzeel
- License: mit
- Created: 2019-02-03T13:12:20.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:51:22.000Z (about 2 years ago)
- Last Synced: 2024-10-02T08:28:55.597Z (4 months ago)
- Topics: browser, deskop, detection, device, efficient, lightweight, mobile, small, tablet, user-agent
- Language: TypeScript
- Homepage:
- Size: 1.39 MB
- Stars: 17
- Watchers: 3
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Detect user-agent
![](http://img.badgesize.io/TimvanScherpenzeel/detect-ua/master/dist/detect-ua.cjs.js.svg?compression=gzip&maxAge=60)
[![npm version](https://badge.fury.io/js/detect-ua.svg)](https://badge.fury.io/js/detect-ua)A small user-agent detection library (1 kB).
Is able to differentiate between mobile, tablet and desktop devices and finds your browser name and version.
## Installation
Make sure you have [Node.js](http://nodejs.org/) installed.
```sh
$ npm install detect-ua
```## Usage
```js
import { DetectUA } from 'detect-ua';const device = new DetectUA();
console.log(device.browser); // -> { name: "Chrome", version: "80.0" }
console.log(device.isMobile); // -> false
console.log(device.isTablet); // -> false
console.log(device.isDesktop); // -> true
console.log(device.isMacOS); // { version: "10" }
console.log(device.isWindows); // -> false
console.log(device.isAndroid); // -> false
console.log(device.isiOS); // -> false
```## Development
```sh
$ yarn start$ yarn lint
$ yarn test
$ yarn build
```## Licence
My work is released under the [MIT license](https://raw.githubusercontent.com/TimvanScherpenzeel/detect-ua/master/LICENSE).