sua.js

Simple user agent detection library.


Keywords
browser, useragent, nodejs, android, ios, useragent-parser, sua
License
MIT
Install
bower install sua.js#2.2.0

Documentation

☕️ sua.js

MIT License Build Status npm version

A simple User-Agent string parser.

(Node.js or Browser supported)

🔰 Install

$ npm install sua.js
or
$ bower install sua.js

🎬 Quick Start

Browser

<script src="sua.js" />

<script>
var sua = new SUA('Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1');

if (!!sua.ios11) {
  // OK!!
}
</script>

NodeJS

var SUA = require('sua.js');
var sua = new SUA('Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1');
if (!!sua.ios11) {
  // OK!!
}

Feature

Supported Browsers

  • ua.Android 2.1
  • ua.Android 2.2
  • ua.Android 2.3
  • ua.Android 3.x
  • ua.Android 4.x
  • ua.Android 5.0
  • ua.Android 5.1
  • ua.Android 6.x
  • ua.Android 7.0
  • ua.Android 7.1
  • ua.Android 8.0
  • ua.iphone (IOS4)
  • ua.iphone (IOS5)
  • ua.iphone (IOS6)
  • ua.iphone (IOS7)
  • ua.iphone (IOS8)
  • ua.iphone (IOS9)
  • ua.iphone (IOS10)
  • ua.iphone (IOS11)
  • ua.iphone (IOS12)
  • ua.iphone (IOS4-ipad)
  • ua.iphone (IOS5-ipad)
  • ua.iphone (IOS6-ipad)
  • ua.iphone (IOS7-ipad)
  • ua.iphone (IOS8-ipad)
  • ua.iphone (IOS9-ipad)
  • ua.iphone (IOS10-ipad)
  • ua.iphone (IOS11-ipad)
  • ua.iphone (IOS12-ipad)
  • ua.iphone5 (hardware)
  • ua.blackberry
  • ua.webos
  • ua.touchpad
  • ua.kindle
  • ua.silk
  • ua.bb10
  • ua.rimtabletos
  • ua.playbook
  • ua.ds
  • ua.psp
  • ua.psvita
  • ua.windowsphone
  • ua.safari
  • ua.xbox
  • ua.ie11 Edge
  • ua.ie11
  • ua.ie10
  • ua.ie9
  • ua.android.firefox
  • ua.webview.twitter
  • ua.chrome pc
  • ua.firefox pc
  • ua.safari pc
  • ua.vivaldi
  • ua.wiiu (Wii U)
  • ua.nintendo_switch (Nintendo Switch)
  • ua.chromecast
  • ua.roku.ultra
  • ua.amazon.4k
  • ua.fire.tv
  • ua.google.nexus.player
  • ua.apple.tv
  • ua.playstation.3
  • ua.playstation.4

🗳 File size

sua.js (size: 14K)
sua.min.js (size: 5.2K) minified with uglify2

🏗 Build

$ npm run build # output: sua.min.js

🐛 Test

Browser : $ ./spec/index.html

Terminal : $ npm test

📄 License

@see : LICENSE