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
- Import the default export function.
- Pass the User-Agent string (from the http-headers of the request) to the function.
- 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);
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).