Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Connect middleware to check useragent for mobile or tablet devices.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
index.js
package.json

README.md

Connect Mobile Detection

Build Status

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

Adds boolean mobile, phone, 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.phone);
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.phone);
  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.

Something went wrong with that request. Please try again.