The most comprehensive, compact, & up-to-date isomorphic JavaScript library to detect user's Browser, Engine, OS, CPU, and Device type/model. Runs either in browser (client-side) or node.js (server-side).
import { UAParser } from 'ua-parser-js';
// 1. Problem:
// Imagine getting this wild user-agent string from a visitor:
const ua = `Mozilla/5.0 (Linux; Android 10; STK-LX1
Build/HONORSTK-LX1; wv) AppleWebKit/537.36 (KHTML,
like Gecko) Version/4.0 Chrome/110.0.5481.153 Mobile
Safari/537.36 musical_ly_2022803040 JsSdk/1.0
NetType/WIFI Channel/huaweiadsglobal_int
AppName/musical_ly app_version/28.3.4 ByteLocale/en
ByteFullLocale/en Region/IQ Spark/1.2.7-alpha.8
AppVersion/28.3.4 PIA/1.5.11 BytedanceWebview/d8a21c6`;
// Note: this is a real user-agent (what???)
// 2. Solution:
// Just pass the complex user-agent string to `UAParser`
const parser = new UAParser(ua);
// 3. Result:
// And voila!
console.log(parser.getBrowser());
// { name : "TikTok", version : "28.3.4", major : "28", type: undefined }
console.log(parser.getCPU());
// { architecture : undefined }
console.log(parser.getEngine());
// { name : "Blink", version : "110.0.5481.153" }
console.log(parser.getDevice());
// { type : "mobile", vendor : "Huawei", model : "STK-LX1" }
console.log(parser.getOS());
// { name : "Android", version : "10" }
console.log(parser.getResult());
/*
{
ua: "Mozilla/5.0 (Linux; Android 10; STK-LX1 Build/HONORSTK-LX1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/110.0.5481.153 Mobile Safari/537.36 musical_ly_2022803040 JsSdk/1.0 NetType/WIFI Channel/huaweiadsglobal_int AppName/musical_ly app_version/28.3.4 ByteLocale/en ByteFullLocale/en Region/IQ Spark/1.2.7-alpha.8 AppVersion/28.3.4 PIA/1.5.11 BytedanceWebview/d8a21c6",
browser: {
name: "TikTok",
version: "28.3.4",
major: "28"
},
cpu: {},
device: {
type: "mobile",
model: "STK-LX1",
vendor: "Huawei"
},
engine: {
name: "Blink",
version: "110.0.5481.153"
},
os: {
name: "Android",
version: "10"
}
}
*/
// 4. Conclusion:
// The visitor is browsing from a TikTok app using an Android-powered Huawei device
// Phew! Thanks, UAParser.js!
- Live demo: https://uaparser.dev
- v1.0: https://github.com/faisalman/ua-parser-js/tree/1.0.38#documentation
- v2.0: https://docs.uaparser.dev
Before upgrading from v0.7
/ v1.0
, please read CHANGELOG to
see what's new & breaking.
Open-Source Editions | PRO / Commercial Editions | ||||
---|---|---|---|---|---|
License options | MIT (v1.x) | AGPL (v2.x) | PRO Personal | PRO Business | PRO Enterprise |
Browser detection | ✅ | ✅ | ✅ | ✅ | |
CPU detection | ✅ | ✅ | ✅ | ✅ | |
Device detection | ✅ | ✅ | ✅ | ✅ | |
Engine detection | ✅ | ✅ | ✅ | ✅ | |
OS detection | ✅ | ✅ | ✅ | ✅ | |
Enhanced detection | ⛔️ | ✅ | ✅ | ✅ | ✅ |
Client Hints support | ⛔️ | ✅ | ✅ | ✅ | ✅ |
Extras (Apps, Bots, Libs, Emails, Media Players, etc) | ⛔️ | ✅ | ✅ | ✅ | ✅ |
CommonJS support | ✅ | ✅ | ✅ | ✅ | ✅ |
ES modules support | ⛔️ | ✅ | ✅ | ✅ | ✅ |
npm module available | ✅ | ✅ | ✅ | ✅ | ✅ |
TypeScript declarations available | ✅ | ✅ | ✅ | ✅ | |
Allowed for commercial use | ✅ | ✅ | ⛔️ | ✅ | ✅ |
Permissive (non-copyleft) license | ✅ | ⛔️ | ✅ | ✅ | ✅ |
Unlimited use per 1 license | ✅ | ✅ | ✅ | ✅ | |
1-year support | ⛔️ | ⛔️ | ✅ | ✅ | ✅ |
Lifetime updates | ✅ | ✅ | ✅ | ✅ | ✅ |
Price | FREE (License) | FREE (License) | $12 (License) | $25 (License) | $500 (License) |
GET THE PRO PACKAGES 📥 |
Please read CONTRIBUTING guide first for the instruction details.
Made with contributors-img.