Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

is-ua-browser

A lightweight library to detect if a User-Agent is a browser.

browsercheck, user-agent, browser-detection, ua-parser, browserdetector, browser-detector, typescript, browser-check

readme

This is a lightweight library built on top of ua-parser-js that provides an instant method to determine whether a request came from a client using a browser.

How to Use

  1. Import the default export function.
  2. Pass the User-Agent string (from the http-headers of the request) to the function.
  3. The function will return a boolean indicating whether the User-Agent corresponds to a browser.

Example:

const isBrowser = require("is-ua-browser");

const userAgent = req.headers["user-agent"];
const isRequestFromBrowser = isBrowser(userAgent);

console.log(isRequestFromBrowser); // true or fase

Frequently Asked Questions (FAQ)

  • Q: If a client sent a request using a mobile browser app, would it work? A: Yes! This library detects any browser, including those on mobile devices (e.g., Chrome Mobile, Safari Mobile).