Author: | sibiraj-s |
---|---|
Views Total: | 55 views |
Official Page: | Go to website |
Last Update: | October 25, 2023 |
License: | MIT |
Preview:

Description:
Just another browser detection library to detect browser and platform properties for both browser and node.js.
Supported Browsers:
- Chrome
- Firefox
- Internet Explorer
- MS Edge
- Safari
- Opera
- Samsung Browser
- Brave
- Electron
Supported Platforms:
- Macintosh
- Windows
- Linux
- Windows Phone
- Android
- Android Tablet
- iPad
- iPhone
- Chrome OS
- Xbox
How to use it:
1. Install and import the ‘browser-dtector’.
# Yarn $ yarn add browser-dtector # NPM $ npm install browser-dtector --save
import BrowserDtector from 'browser-dtector';
2. Or import it from a CDN.
import BrowserDetector from 'https://cdn.jsdelivr.net/npm/browser-dtector/dist/browser-dtector.js';
3. Initialize the library.
const browser = new BrowserDtector(window.navigator.userAgent); // or new BrowserDtector()
4. Parse useragent info.
browser.parseUserAgent(); => { name: "Safari" platform: "IPhone" userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1" version: "13.0.3" shortVersion: "13" isAndroid: false isTablet: false isMobile: true isDesktop: false isWebkit: true isIE: false }
5. Get browser info.
browser.getBrowserInfo(); => { name: "Safari" platform: "IPhone" userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1" version: "13.0.3" shortVersion: "13" }
6. Get useragent for current instance
browser.userAgent [string | null];
Changelog:
v4.0.0 (10/25/2022)
- export KnownBrowsers and KnownPlatforms constants
- fix exports configuration and type declaration for node environments
- removed umd build
- use named exports for cjs formats
v3.4.0 (07/12/2022)
- detect opera touch browser
v3.2.0 (01/27/2022)
- Detect electron browser
- Bug Fixes
v3.1.2 (07/29/2021)
- chore: rename variables
v3.1.2 (12/15/2020)
- update LICENSE
v3.1.1 (12/02/2020)
- Supports Brave browser
- chore: replace inquirer with prompts
- Bugfix
v3.0.2 (07/01/2020)
- Bugfixed