Detect What Device and Browser You’re Using – get-browser

Category: Javascript , Recommended | May 30, 2019
Author:yankouskia
Views Total:386 views
Official Page:Go to website
Last Update:May 30, 2019
License:MIT

Preview:

Detect What Device and Browser You’re Using – get-browser

Description:

get-browser is a pure JavaScript library that tells you what device and web/mobile browser you’re using.

Supports Desktop, Mobile, Android, iOS, Chrome, Firefox, Safari, Opera, IE, Edge, etc.

See also:

How to use it:

Install and import modules.

# Yarn
$ yarn add get-browser
# NPM
$ npm install get-browser --save
import {
  browsers,
  detect,
  isMobile,
  isAndroid,
  isChrome,
  isEdge,
  isFirefox,
  isIE,
  isOpera,
  isSafari,
} from 'get-browser';

Or directly import the umd version in the document.

<script src="./dist/index.js"></script>

Detect and return the browser name.

const browser = detect();

Detect what device and browser you’re using.

// if is mobile
const instance = isMobile();
// if is Android
const instance = isAndroid();
// if is Chrome
const instance = isChrome();
// if is Firefox
const instance = isFireFox();
// if is Safari
const instance = isSafari();
// if is MS Edge
const instance = isEdge();
// if is IE
const instance = isIE();
// if is Opera
const instance = isOpera();

You Might Be Interested In:


Leave a Reply