From 5032e0ee715fc5bedd51880f0d96c1bb725e443e Mon Sep 17 00:00:00 2001
From: naorpeled 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. Check it out on this page: https://bowser-js.github.io/bowser-online/. 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 First of all, require the library. This is a UMD Module, so it will work for AMD, TypeScript, ES6, and CommonJS module systems.Overview
+Overview
⚠️ Version 2.0 breaking changes ⚠️
npm install bowser@1.9.4.Use cases
+Use cases
const Bowser = require("bowser"); // CommonJS
@@ -98,14 +98,14 @@ import Bowser from "bowser"; // ES6 (and TypeScript with --esModuleInt
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.
-Often we need to pick users' browser properties such as the name, the version, the rendering engine and so on. Here is an example how to do it with Bowser:
const browser = Bowser.getParser(window.navigator.userAgent);
console.log(`The current browser name is "${browser.getBrowserName()}"`);
// The current browser name is "Internet Explorer"
-Modern browsers support User-Agent Client Hints, which provide a more privacy-friendly and structured way to access browser information. Bowser can use Client Hints data to improve browser detection accuracy.
// Pass Client Hints as the second parameter
const browser = Bowser.getParser(
@@ -190,7 +190,7 @@ console.log(browser.getBrowser());
// Same output structure, but with enhanced detection from Client Hints
-You could want to filter some particular browsers to provide any special support for them or make any workarounds. It could look like this:
const browser = Bowser.getParser(window.navigator.userAgent);