is-ua-browser
Version:
A lightweight library to detect if a User-Agent is a browser.
23 lines (14 loc) • 862 B
Markdown
# 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:
```js
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).