Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

detect-mobile-browser

5.0.0 • Public • Published

Build NPM Version NPM Downloads Inline docs Coverage Status
NPM

Detect Mobile Browser

Small plugin to detect mobile browser

Usage Frontend:-

alert(SmartPhone.isAndriod());

OR

alert(SmartPhone.isAny());

OR (browserify):

var SmartPhone = require('detect-mobile-browser')(false);
module.exports = (function($) {
    $(document).ready(function() {
      alert(SmartPhone.isAny());
    });
})(jQuery);

Usage Backend:-

Use as an ExpressJS middleware

var mobileBrowser = require('detect-mobile-browser');
 
...
...
 
app.use(mobileBrowser());
 
app.get('/', function (req, res){
    ...
    ...
    //in req
    console.log(req.SmartPhone.isAny());
 
    ...
    ...
 
    //in res locals to use in templates
    console.log(res.locals.SmartPhone.isAny());
 
    ...
    ...
 
});
 

Bower

$ bower install browser-detector --save

NPM

$ npm install detect-mobile-browser --save

SPM

$ spm install detect-mobile-browser --save

List of detection functions:

  • isAndroid
  • isBlackBerry
  • isBlackBerryPlayBook
  • isBlackBerry10
  • isIOS
  • isIPhone
  • isIPad
  • isIPod
  • isOpera
  • isWindows
  • isWindowsMobile
  • isWindowsDesktop
  • isFireFox
  • isNexus
  • isKindleFire
  • isPalm
  • isAny

install

npm i detect-mobile-browser

Downloadsweekly downloads

382

version

5.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability