auth0/mobileagent

Name: mobileagent

Owner: Auth0

Description: Easy mobile browser detection helper for Node.js

Forked from: hisayan/mobileagent

Created: 2016-08-01 10:53:30.0

Updated: 2016-08-01 10:53:31.0

Pushed: 2016-08-01 11:11:12.0

Homepage: null

Size: 7

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

install mobile-agent

mobile-agent

Easy mobile browser detection helper for Node.js

Simple Example (Node HTTP):

rites the user agent obj. out to the screen
http = require('http');
util = require('util');
ua   = require('mobile-agent');

.createServer(function (req, res) {
var agent = ua(req.headers['user-agent']);

res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(util.inspect(agent));
isten(8080);

.log("Server listening on port 8080.");

Example output:

bile: false,
S: false,
hone: false,
ad: false,
droid: false,
bOS: false,
c: '10.8.1',
ndows: false,
her: false,
owser: { 
name: 'safari', 
version: '536.25' 



Express example:

ua   = require('mobile-agent');

get('/', function(req, res) {
var agent = ua(req.headers['user-agent'])

if(agent.Mobile === true) {
    res.render('mobile', {
        foo: 'bar'
    });
} else {
    res.render('desktop', {
        foo: 'bar'
    });
}


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.