bowser vs detect-browser vs device vs mobile-detect vs platform vs ua-parser-js
User Agent Parsing and Device Detection in JavaScript Applications
bowserdetect-browserdevicemobile-detectplatformua-parser-jsSimilar Packages:

User Agent Parsing and Device Detection in JavaScript Applications

These six npm packages help developers identify browsers, devices, and operating systems by parsing user agent strings. ua-parser-js and bowser offer comprehensive parsing with detailed browser, device, and OS information. detect-browser focuses on browser identification with minimal footprint. mobile-detect specializes in distinguishing mobile vs desktop environments. platform provides cross-platform environment detection. device offers simple device type detection. Each serves different needs depending on whether you need detailed parsing, mobile-specific detection, or lightweight browser identification.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
bowser05,734258 kB913 months agoMIT
detect-browser069827 kB464 years agoMIT
device079-45 years agoMIT
mobile-detect04,142-135 years agoMIT
platform03,249-346 years agoMIT
ua-parser-js010,1081.31 MB153 months agoAGPL-3.0-or-later

User Agent Parsing and Device Detection: A Technical Deep-Dive

When building web applications that need to adapt to different browsers, devices, or operating systems, you'll often need to parse user agent strings. The six packages we're comparing (bowser, detect-browser, device, mobile-detect, platform, ua-parser-js) all solve this problem but with different approaches, feature sets, and maintenance status. Let's examine how they work in real-world scenarios.

⚠️ Maintenance Status: What You Need to Know First

Before diving into features, check the current maintenance status of each package:

  • platform - ⚠️ Deprecated. The maintainers have marked this package as deprecated. Do not use in new projects.
  • device - ⚠️ Limited maintenance. Last significant updates were several years ago. Use with caution.
  • bowser, detect-browser, mobile-detect, ua-parser-js - ✅ Actively maintained with recent updates.

💡 Recommendation: For new projects, prioritize bowser, ua-parser-js, or detect-browser. Avoid platform in new codebases.

🔍 Parsing Depth: How Much Information Do You Get?

Different packages extract different levels of detail from user agent strings.

ua-parser-js provides the most comprehensive parsing with three main categories:

import UAParser from 'ua-parser-js';

const parser = new UAParser();
const result = parser.getResult();

// Browser details
console.log(result.browser.name);    // "Chrome"
console.log(result.browser.version); // "120.0.6099.109"

// Device details
console.log(result.device.type);     // "mobile" | "tablet" | "console" | "wearable"
console.log(result.device.model);    // "iPhone" | "Samsung Galaxy"

// OS details
console.log(result.os.name);         // "iOS"
console.log(result.os.version);      // "17.2"

bowser offers similar depth with a cleaner API for version comparisons:

import bowser from 'bowser';

const browser = bowser.getParser(window.navigator.userAgent);

// Browser info
console.log(browser.getBrowserName());    // "Chrome"
console.log(browser.getBrowserVersion()); // "120.0.6099.109"

// OS info
console.log(browser.getOSName());         // "Windows"
console.log/browser.getOSVersion());      // "11"

// Device type
console.log(browser.getPlatformType());   // "desktop" | "mobile" | "tablet"

detect-browser focuses on browser identification only:

import { detect } from 'detect-browser';

const browser = detect();

console.log(browser.name);    // "chrome"
console.log(browser.version); // "120.0.6099.109"
console.log(browser.os);      // "Mac OS"
// No device type information available

mobile-detect specializes in mobile vs desktop distinction:

import MobileDetect from 'mobile-detect';

const md = new MobileDetect(window.navigator.userAgent);

console.log(md.mobile());       // "iPhone" or null
console.log(md.tablet());       // "iPad" or null
console.log(md.phone());        // "iPhone" or null
console.log(md.userAgent());    // Full user agent string
console.log(md.is('iPhone'));   // true/false

device provides simple device type detection:

import device from 'device';

console.log(device.type());     // "mobile" | "tablet" | "desktop"
console.log(device.name());     // Device name if recognized
// Limited browser and OS information

platform (deprecated) provided cross-environment info:

import platform from 'platform';

console.log(platform.name);           // "Chrome"
console.log(platform.version);        // "120.0.6099.109"
console.log(platform.os.family);      // "OS X"
console.log(platform.layout);         // "WebKit"
// Package is deprecated - do not use in new projects

🎯 Browser Version Comparison: Which Packages Support It?

When you need to check if a browser meets minimum version requirements, API design matters.

bowser has built-in version comparison methods:

import bowser from 'bowser';

const browser = bowser.getParser(window.navigator.userAgent);

// Check minimum version
const isSupported = browser.satisfies({
  chrome: ">=90",
  firefox: ">=85",
  safari: ">=14"
});

// Or check specific browser
const isChrome = browser.is('Chrome');
const chromeVersion = browser.getBrowserVersion();

ua-parser-js requires manual version comparison:

import UAParser from 'ua-parser-js';

const parser = new UAParser();
const result = parser.getResult();

// Manual version comparison
const isSupported = 
  result.browser.name === 'Chrome' && 
  parseInt(result.browser.version) >= 90;

detect-browser also requires manual comparison:

import { detect } from 'detect-browser';

const browser = detect();

const isSupported = 
  browser.name === 'chrome' && 
  parseFloat(browser.version) >= 90;

mobile-detect, device, and platform do not provide built-in version comparison utilities. You'll need to implement your own logic.

🌐 Environment Support: Browser vs Node.js

Not all packages work in every JavaScript environment.

Works in both Browser and Node.js:

// ua-parser-js - works everywhere
import UAParser from 'ua-parser-js';
const parser = new UAParser(userAgentString); // Pass UA string in Node.js

// detect-browser - works everywhere
import { detect } from 'detect-browser';
const browser = detect(); // Auto-detects in browser, needs UA in Node

// bowser - works everywhere
import bowser from 'bowser';
const browser = bowser.getParser(userAgentString);

Primarily Browser-Focused:

// mobile-detect - designed for browser
import MobileDetect from 'mobile-detect';
const md = new MobileDetect(window.navigator.userAgent);
// In Node.js, you must pass the UA string manually

// device - primarily browser
import device from 'device';
// Relies on navigator.userAgent in browser context

// platform - deprecated but worked everywhere
import platform from 'platform';
// No longer recommended for new projects

📱 Mobile Detection: Specialized vs General Purpose

If mobile detection is your primary need, some packages are better suited than others.

mobile-detect provides the most detailed mobile information:

import MobileDetect from 'mobile-detect';

const md = new MobileDetect(window.navigator.userAgent);

// Specific device checks
if (md.mobile()) {
  if (md.phone()) {
    // Show phone-specific UI
  } else if (md.tablet()) {
    // Show tablet-specific UI
  }
}

// Check specific devices
if (md.is('iPhone')) {
  // iOS-specific handling
}

if (md.is('AndroidOS')) {
  // Android-specific handling
}

bowser provides mobile detection as part of broader parsing:

import bowser from 'bowser';

const browser = bowser.getParser(window.navigator.userAgent);

if (browser.getPlatformType() === 'mobile') {
  // Mobile-specific logic
}

if (browser.getPlatformType() === 'tablet') {
  // Tablet-specific logic
}

ua-parser-js includes device type in results:

import UAParser from 'ua-parser-js';

const parser = new UAParser();
const result = parser.getResult();

if (result.device.type === 'mobile') {
  // Mobile-specific logic
}

if (result.device.type === 'tablet') {
  // Tablet-specific logic
}

device focuses solely on device type:

import device from 'device';

switch (device.type()) {
  case 'mobile':
    // Mobile handling
    break;
  case 'tablet':
    // Tablet handling
    break;
  case 'desktop':
    // Desktop handling
    break;
}

detect-browser and platform do not provide dedicated mobile detection APIs.

🔧 API Design: How Developer-Friendly Is Each Package?

The way each package structures its API affects code readability and maintenance.

bowser uses a parser instance pattern with chainable methods:

import bowser from 'bowser';

const browser = bowser.getParser(ua);

// Fluent, readable API
const info = {
  name: browser.getBrowserName(),
  version: browser.getBrowserVersion(),
  os: browser.getOSName(),
  platform: browser.getPlatformType()
};

ua-parser-js uses a result object pattern:

import UAParser from 'ua-parser-js';

const parser = new UAParser(ua);
const result = parser.getResult();

// All data in one object
const info = {
  name: result.browser.name,
  version: result.browser.version,
  os: result.os.name,
  device: result.device.type
};

detect-browser returns a simple object immediately:

import { detect } from 'detect-browser';

// One function call, immediate result
const browser = detect();

// Simple property access
console.log(browser.name, browser.version);

mobile-detect uses a class instance with specific methods:

import MobileDetect from 'mobile-detect';

const md = new MobileDetect(ua);

// Method-based queries
const isMobile = !!md.mobile();
const isTablet = !!md.tablet();
const deviceName = md.device();

🚨 Edge Cases: Handling Unknown or Spoofed User Agents

User agent strings can be missing, malformed, or intentionally spoofed. Here's how each package handles edge cases:

ua-parser-js returns structured data even for unknown agents:

import UAParser from 'ua-parser-js';

const parser = new UAParser('Unknown User Agent');
const result = parser.getResult();

// Returns empty strings or undefined for unknown values
console.log(result.browser.name); // undefined or empty string
console.log(result.device.type);  // undefined

bowser provides fallback values:

import bowser from 'bowser';

const browser = bowser.getParser('Unknown User Agent');

// Returns empty strings for unknown values
console.log(browser.getBrowserName()); // ""
console.log(browser.getBrowserVersion()); // ""

detect-browser returns null for unrecognizable agents:

import { detect } from 'detect-browser';

const browser = detect('Unknown User Agent');

// Returns null if nothing can be detected
if (browser === null) {
  // Handle unknown browser
}

📊 Real-World Use Cases: Which Package Fits Your Needs?

Analytics and Tracking

For detailed user environment analytics, you need comprehensive data:

// Best choice: ua-parser-js
import UAParser from 'ua-parser-js';

function trackPageView() {
  const parser = new UAParser();
  const result = parser.getResult();
  
  analytics.track('page_view', {
    browser: result.browser.name,
    browserVersion: result.browser.version,
    os: result.os.name,
    deviceType: result.device.type
  });
}

Browser Compatibility Checks

When you need to enforce minimum browser versions:

// Best choice: bowser
import bowser from 'bowser';

function checkBrowserSupport() {
  const browser = bowser.getParser(window.navigator.userAgent);
  
  const isSupported = browser.satisfies({
    chrome: ">=90",
    firefox: ">=85",
    edge: ">=90",
    safari: ">=14"
  });
  
  if (!isSupported) {
    showUnsupportedBrowserWarning();
  }
}

Mobile-First Responsive Design

When mobile detection drives your UI decisions:

// Best choice: mobile-detect
import MobileDetect from 'mobile-detect';

function initializeApp() {
  const md = new MobileDetect(window.navigator.userAgent);
  
  if (md.phone()) {
    loadMobileComponents();
  } else if (md.tablet()) {
    loadTabletComponents();
  } else {
    loadDesktopComponents();
  }
}

Simple Browser Detection

When you just need to know which browser is running:

// Best choice: detect-browser
import { detect } from 'detect-browser';

function logBrowserInfo() {
  const browser = detect();
  
  if (browser) {
    console.log(`Running on ${browser.name} ${browser.version}`);
  }
}

🔄 Server-Side Rendering Considerations

When rendering on the server, you don't have access to window.navigator.userAgent. You need to pass the user agent string explicitly:

// All packages support passing UA string explicitly

// bowser
const browser = bowser.getParser(req.headers['user-agent']);

// ua-parser-js
const parser = new UAParser(req.headers['user-agent']);

// detect-browser
const browser = detect(req.headers['user-agent']);

// mobile-detect
const md = new MobileDetect(req.headers['user-agent']);

📋 Summary: Key Differences at a Glance

Featurebowserdetect-browserdevicemobile-detectplatformua-parser-js
Maintenance✅ Active✅ Active⚠️ Limited✅ Active❌ Deprecated✅ Active
Browser Info✅ Detailed✅ Basic❌ Minimal⚠️ Limited✅ Detailed✅ Detailed
Device Info✅ Type only❌ None✅ Type only✅ Detailed✅ Detailed✅ Detailed
OS Info✅ Yes✅ Basic❌ None⚠️ Limited✅ Yes✅ Yes
Version Compare✅ Built-in❌ Manual❌ Manual❌ Manual❌ Manual❌ Manual
Mobile Focus⚠️ General❌ None⚠️ General✅ Specialized⚠️ General⚠️ General
Node.js Support✅ Yes✅ Yes⚠️ Limited✅ Yes✅ Yes✅ Yes

💡 Final Recommendations

For most new projects: Start with bowser or ua-parser-js. They offer the best balance of features, maintenance, and API design.

For mobile-specific needs: Choose mobile-detect if mobile vs desktop distinction is your primary concern.

For lightweight browser detection: Use detect-browser when you only need basic browser name and version.

Avoid in new projects: platform (deprecated) and device (limited maintenance).

For analytics platforms: ua-parser-js provides the most comprehensive data for user environment tracking.

For browser compatibility checks: bowser has the best built-in version comparison utilities.

Remember: User agent parsing is inherently unreliable. User agents can be spoofed, and new browsers may not be recognized immediately. Use these tools for progressive enhancement and analytics, not for critical security decisions or blocking access.

How to Choose: bowser vs detect-browser vs device vs mobile-detect vs platform vs ua-parser-js

  • bowser:

    Choose bowser when you need detailed browser, engine, and OS information with a clean, promise-like API. It excels at browser version comparisons and feature detection workflows. Best for applications that need to apply browser-specific fixes or track detailed analytics about user environments.

  • detect-browser:

    Choose detect-browser when you need lightweight browser detection without heavy parsing overhead. It works in both Node.js and browser environments. Ideal for simple use cases where you only need to identify the browser name and version without deep device or OS details.

  • device:

    Choose device when you need ultra-simple device type detection (mobile, tablet, desktop) with minimal configuration. It's one of the lighter options but has less active maintenance. Best for projects that only need basic device categorization without detailed browser or OS information.

  • mobile-detect:

    Choose mobile-detect when your primary concern is distinguishing mobile devices from desktop browsers. It provides detailed mobile-specific information like phone vs tablet distinction. Ideal for responsive design decisions, mobile-specific redirects, or analytics focused on mobile traffic.

  • platform:

    Choose platform when you need cross-environment detection that works consistently across browsers, Node.js, and other JavaScript runtimes. It's maintained by the lodash team and offers reliable, standardized output. Best for applications that run in multiple environments and need consistent detection logic.

  • ua-parser-js:

    Choose ua-parser-js when you need the most comprehensive user agent parsing with extensive browser, device, and OS coverage. It has the largest database of user agent patterns. Ideal for analytics platforms, security applications, or any project requiring detailed user environment fingerprinting.

README for bowser

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!

Financial Contributors on Open Collective Downloads

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. Check it out on this page: https://bowser-js.github.io/bowser-online/.

⚠️ 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 = require("bowser"); // CommonJS

import * as Bowser from "bowser"; // TypeScript

import Bowser from "bowser"; // 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

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"

Using User-Agent Client Hints

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(
  window.navigator.userAgent,
  window.navigator.userAgentData
);

console.log(`The current browser name is "${browser.getBrowserName()}"`);
// More accurate detection using Client Hints

Working with Client Hints

Bowser provides methods to access and query Client Hints data:

const browser = Bowser.getParser(
  window.navigator.userAgent,
  window.navigator.userAgentData
);

// Get the full Client Hints object
const hints = browser.getHints();
// Returns the ClientHints object or null if not provided

// Check if a specific brand exists
if (browser.hasBrand('Google Chrome')) {
  console.log('This is Chrome!');
}

// Get the version of a specific brand
const chromeVersion = browser.getBrandVersion('Google Chrome');
console.log(`Chrome version: ${chromeVersion}`);

The Client Hints object structure:

{
  brands: [
    { brand: 'Google Chrome', version: '131' },
    { brand: 'Chromium', version: '131' },
    { brand: 'Not_A Brand', version: '24' }
  ],
  mobile: false,
  platform: 'Windows',
  platformVersion: '15.0.0',
  architecture: 'x86',
  model: '',
  wow64: false
}

Note: Client Hints improve detection for browsers like DuckDuckGo and other Chromium-based browsers that may have similar User-Agent strings. When Client Hints are not provided, Bowser falls back to standard User-Agent string parsing.

or

const browser = Bowser.getParser(window.navigator.userAgent);
console.log(browser.getBrowser());

// outputs
{
  name: "Internet Explorer"
  version: "11.0"
}

or

console.log(Bowser.parse(window.navigator.userAgent));

// outputs
{
  browser: {
    name: "Internet Explorer"
    version: "11.0"
  },
  os: {
    name: "Windows"
    version: "NT 6.3"
    versionName: "8.1"
  },
  platform: {
    type: "desktop"
  },
  engine: {
    name: "Trident"
    version: "7.0"
  }
}

You can also use Bowser.parse() with Client Hints:

console.log(Bowser.parse(window.navigator.userAgent, window.navigator.userAgentData));

// Same output structure, but with enhanced detection from Client Hints

Filtering browsers

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);
const isValidBrowser = browser.satisfies({
  // declare browsers per OS
  windows: {
    "internet explorer": ">10",
  },
  macos: {
    safari: ">10.1"
  },

  // per platform (mobile, desktop or tablet)
  mobile: {
    safari: '>=9',
    'android browser': '>3.10'
  },

  // or in general
  chrome: "~20.1.1432",
  firefox: ">31",
  opera: ">=22",

  // also supports equality operator
  chrome: "=20.1.1432", // will match particular build only

  // and loose-equality operator
  chrome: "~20",        // will match any 20.* sub-version
  chrome: "~20.1"       // will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1)
});

Settings for any particular OS or platform has more priority and redefines settings of standalone browsers. Thus, you can define OS or platform specific rules and they will have more priority in the end.

More of API and possibilities you will find in the docs folder.

Browser names for .satisfies()

By default you are supposed to use the full browser name for .satisfies. But, there's a short way to define a browser using short aliases. The full list of aliases can be found in the file.

Similar Projects

  • Kong - A C# port of Bowser.

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

License

Licensed as MIT. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.