Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
parser
✓ const parser = require('useragent-parser-js');
✗ import parser from 'useragent-parser-js';
The library uses CommonJS; ESM import is not supported.
parse
✓ const result = parser.parse(uaString);
✗ parser.parse(uaString, callback);
parse() takes a single string argument synchronously, no callback.
default import
✓ var parser = require('useragent-parser-js');
✗ var parse = require('useragent-parser-js').parse;
The module exposes a single function directly, not as a named export.
Demonstrates basic usage: require the module, parse a user-agent string, and log the full result object with flags and properties.
const parser = require('useragent-parser-js');
const ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36';
const result = parser.parse(ua);
console.log(result);
// {
// isMobile: false,
// isDesktop: true,
// isTablet: false,
// isiPad: false,
// isiPod: false,
// isiPhone: false,
// isAndroid: false,
// isBlackberry: false,
// isOpera: false,
// isIE: false,
// isIECompatibilityMode: false,
// isSafari: false,
// isFirefox: false,
// isWebkit: true,
// isChrome: true,
// isKonqueror: false,
// isOmniWeb: false,
// isSeaMonkey: false,
// isFlock: false,
// isAmaya: false,
// isEpiphany: false,
// isWindows: true,
// isLinux: false,
// isLinux64: false,
// isMac: false,
// isChromeOS: false,
// isBada: false,
// isSamsung: false,
// isRaspberry: false,
// isBot: false,
// isCurl: false,
// isAndroidTablet: false,
// isWinJs: false,
// isKindleFire: false,
// isSilk: false,
// silkAccelerated: false,
// browser: 'Chrome',
// version: '91.0.4472.124',
// os: 'Windows 10',
// platform: 'Microsoft Windows',
// source: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
// }
Errors
Common errors & fixes
Cannot find module 'useragent-parser-js'
The package name in npm is 'useragent-parser-js' but older documentation refers to 'useragent-parser'.
fixInstall using 'npm install useragent-parser-js' and require the correct name.
TypeError: parser.parse is not a function
Importing the library incorrectly as a named export or using ES6 import syntax.
fixUse `const parser = require('useragent-parser-js');` and then `parser.parse(ua);`. Audit
Dependencies
No dependency data recorded yet.