Skip to content

getBrowser(): IBrowser

Get browser name, full version, & major version from user-agent string.

Properties of IBrowser

js
// Browser object is structured as follow:
{ 
    name: "", 
    version: "", 
    major: "", 
    type: ""
}

name?: string

Name of current browser.

INFO

See list of possible browser name here.


version?: string

Version of current browser, determined dynamically from user-agent data, or undefined if browser version is not found.


major?: string

Major number derived from the first number in version, following semver🡭, e.g: if version is 5.1.21214, then major would be 5.

INFO

  • undefined if the browser has no version
  • "" if the first token in version is not a Number

type?: string

Type of current browser, e.g: email, inapp, crawler. See list of possible browser type here.

INFO

Find the example of various browser types in ua-parser-js/extensions submodule.

Methods of IBrowser

Inherited from IData:

Code Example

js
const operamini = 'Opera/9.80 (J2ME/MIDP; Opera Mini/5.1.21214/19.916; U; en) Presto/2.5.25'
const parser = new UAParser(operamini);

console.log(parser.getBrowser());
// { name : "Opera Mini", version : "5.1.21214", major : "5" }

UAParser.js v2 is licensed under AGPLv3 or PRO licenses.