Skip to content

Connect middleware to check useragent for mobile or tablet devices.

License

Notifications You must be signed in to change notification settings

af/connect-mobile-detection

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connect Mobile Detection

Build Status

Connect middleware which uses the client useragent to detect mobile and tablet devices.

Adds boolean mobile and tablet properties to req.

Note

It is not always wise to rely on useragents to determine mobile and tablet clients.

Usage

For all routes using Connect or Express.

...
var checkMobile = require('connect-mobile-detection');
...
app.use(checkMobile());
...
// inside any route
console.log(req.mobile);
console.log(req.tablet);

For single routes using Express.

...
var checkMobile = require('connect-mobile-detection');
...
app.get('/', checkMobile(), function (req, res) {
  console.log(req.mobile);
  console.log(req.tablet);
});

License

Licensed MIT unless otherwise noted. See LICENSE file.

This module uses public domain code from Chad Smith's detectmobilebrowsers.com project.

About

Connect middleware to check useragent for mobile or tablet devices.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%