Socket
Book a DemoInstallSign in
Socket

bowser-jr

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bowser-jr

Light-weight, composable browser detector

1.0.6
latest
Source
npmnpm
Version published
Weekly downloads
226
352%
Maintainers
1
Weekly downloads
 
Created
Source

Bowser Jr.

A small, lightweight and composable browser detection utility heavily inspired by bowser.

Unit Tests

Installation

Install it using your favourite package manager:

$ npm install bowser-jr
# or
$ yarn add bowser-jr
# or
$ pnpm add bowser-jr

Usage

Now just import getParser and the parsers you need:

import { getParser } from 'bowser-jr';
import { getBrowserName, browserParser } from 'bowser-jr/browser';

const parser = getParser(window.navigator.userAgent, { use: [browserParser] });

console.log(getBrowserName(parser)); // outputs `Firefox`

Using multiple parsers

You can use multiple parsers to extract more information from the user agent:

import { getParser } from 'bowser-jr';
import { browserParser } from 'bowser-jr/browser';
import { engineParser } from 'bowser-jr/engine';
import { osParser } from 'bowser-jr/os';
import { platformParser } from 'bowser-jr/platform';

const parser = getParser(window.navigator.userAgent, {
    use: [browserParser, engineParser, osParser, platformParser],
});

console.log(parser.getResult());

Bowser compat utilities

bowser-jr also comes with a compatibility utility for bowser to make adoption a little easier:

import BowserCompat from 'bowser-jr/compat';

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

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

FAQs

Package last updated on 29 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.