infinity-browser-detect
v1.0.1
Published
A simple utility to detect browser information (name, version, major version, and user agent).
Keywords
Readme
infinity-browser-detect
A simple utility to detect browser information (name, version, major version, and user agent).
Installation
npm install infinity-browser-detectUsage
import { infinityDetectBrowser } from 'infinity-browser-detect';
const browser = infinityDetectBrowser(); // Detects current browser
console.log(browser);
/*
Example Output:
{
browser: "Chrome",
version: "120.0.0.0",
os: "Windows 10",
engine: "Blink",
device: "Desktop",
isMobile: false,
isBot: false,
isHeadless: false,
}
*/
// You can also pass a User Agent string directly:
const info = infinityDetectBrowser("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
console.log(info);infinityDetectBrowser(userAgentString)
userAgentString(Optional): A string representing the User Agent. If not provided,navigator.userAgentwill be used.
Returns an object containing the following properties:
browser: (String) The name of the browser (e.g., "Chrome", "Firefox", "Safari", "Edge", "IE", "Unknown").version: (String) The full version string of the browser.os: (String) The operating system (e.g., "Windows 10", "macOS", "Android", "iOS", "Linux", "Unknown").engine: (String) The rendering engine (e.g., "WebKit", "Gecko", "Blink", "Unknown").device: (String) The device type (e.g., "Desktop", "Mobile", "Tablet", "Bot").isMobile: (Boolean)trueif the device is mobile or tablet,falseotherwise.isBot: (Boolean)trueif the user agent is identified as a bot,falseotherwise.isHeadless: (Boolean)trueif the browser is headless,falseotherwise.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
MIT
