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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
install 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'
});
}