Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

browser-version-detection

pure-js48MIT2.1.8

Browser detection using the user agent, returns the name and version of the browser

browser detection, browser version, rendering engine detection

readme

Detect browser

Build Status codecov Greenkeeper badge Maintainability Test Coverage

Browser detection using the user agent. Tested on most popular browser in the World on October 2017, statistic gets from StatCounter.

It's worth re-iterating: it's very rarely a good idea to use user agent sniffing. You can almost always find a better, more broadly compatible way to solve your problem!

More details here

Usage

Installation

npm i browser-version-detection

Script returns object with browser name and version, for example:

const output = {
  name: 'Chrome',
  version: 62,
}

Call it where you want

browserDetection.detectBrowser(window.navigator);

in case if you need only name

browserDetection.detectBrowserName(window.navigator.userAgent)
`

in case if you need only version

const name = browserDetection.detectBrowserName(window.navigator.userAgent);
browserDetection.detectBrowserVersion(window.navigator, name)
`

Note: also it's possible to use npm instead of yarn. Minified script located in dist/ folder

Contribution

yarn install
yarn run start

Test

yarn test

changelog

Changelog

v2.1.7 (22-1-2018)

Implemented enhancements:

  • added shortening for detectBrowserNameAndVersion() - detectBrowser()