1.0.2 • Published 8 months ago

is-ua-browser v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

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).