Bowser Mini
This is an exact copy of Bowser, except smaller, and only returns something a logger can parse in a much smaller space. Use the below mapper object to translate the short string.
This package is ideal if you're storing log or analytic data.
String format
The string returned is 3 variables, separated by commas.
Variable 1: The Browser/OS/Platform/Engine types.
- Byte 1: Browser
- Byte 2: OS
- Byte 3: Platform
- Byte 4: Engine
Variable 2: The Browser version.
Variable 3: The OS version.
The Mapper Object...
cons mapper = {
browser: { // Byte 1
'A': 'Android Browser',
'a': 'Amazon Silk',
'b': 'Bada',
'B': 'BlackBerry',
'C': 'Chrome',
'c': 'Chromium',
'E': 'Electron',
'e': 'Epiphany',
'F': 'Firefox',
'f': 'Focus',
'g': 'Generic',
'G': 'Googlebot',
'S": 'Google Search',
'X': 'Internet Explorer',
'K': 'K-Meleon',
'm': 'Maxthon',
'x': 'Microsoft Edge',
'z': 'MZ Browser',
'n': 'NAVER Whale Browser',
'O': 'Opera',
'o': 'Opera Coast',
'P': 'PhantomJS',
'L': 'Playstation 4',
'p': 'Puffin',
'u': 'QupZilla',
'Q': 'QQ Browser',
'q': 'QQ Browser Lite',
'S': 'Safari',
'1': 'Sailfish',
'2': 'Samsung Internet for Android',
'3': 'SeaMonkey',
'4': 'Sleipnir',
'5': 'Swing',
'6': 'Tizen',
'7': 'UC Browser',
'8': 'Vivaldi',
'9': 'SlimerJS',
'W': 'WebOS Browser',
'w': 'WeChat',
'Y': 'Yandex Browser',
'?': 'Unknown'
},
os: { // Byte 2
'W': 'Windows',
'w': 'Windows Phone',
'M': 'macOS',
'i': 'iOS',
'A': 'Android',
'W': 'WebOS',
'B': 'BlackBerry',
'b': 'Bada',
'T': 'Tizen',
'L': 'Linux',
'C': 'Chrome OS',
'P': 'PlayStation 4',
'R': 'Roku'
},
platforms: { // Byte 3
'T': 'tablet',
'M': 'mobile',
'D': 'desktop',
'V': 'tv'
},
engines: { // Byte 4
'E': 'EdgeHTML',
'B': 'Blink',
'T': 'Trident',
'P': 'Presto',
'G': 'Gecko',
'W': 'WebKit'
}
}
Bowser
A small, fast and rich-API browser/platform/engine detector for both browser and node.
- Small. Use plain ES5-version which is ~4.8kB gzipped.
- Optimized. Use only those parsers you need — it doesn't do useless work.
- Multi-platform. It's browser- and node-ready, so you can use it in any environment.
Don't hesitate to support the project on Github or OpenCollective if you like it ❤️ Also, contributors are always welcome!
Contents
Overview
The library is made to help to detect what browser your user has and gives you a convenient API to filter the users somehow depending on their browsers.
⚠️ Version 2.0 breaking changes ⚠️
Version 2.0 has drastically changed the API. All available methods are on the docs page.
For legacy code, check out the 1.x branch and install it through npm install bowser@1.9.4
.
Use cases
First of all, require the library. This is a UMD Module, so it will work for AMD, TypeScript, ES6, and CommonJS module systems.
const Bowser = ; // CommonJS ; // TypeScript ; // ES6 (and TypeScript with --esModuleInterop enabled)
By default, the exported version is the ES5 transpiled version, which do not include any polyfills.
In case you don't use your own babel-polyfill
you may need to have pre-built bundle with all needed polyfills.
So, for you it's suitable to require bowser like this: require('bowser/bundled')
.
As the result, you get a ES5 version of bowser with babel-polyfill
bundled together.
You may need to use the source files, so they will be available in the package as well.
Browser props detection
console; // outputs"CWDB,79.0.3945.88,NT 10.0"