I intend for my nodejs/express app to be used by mobile users only, with dekstop users receiving completely different content. How can I detect if the client is on a mobile device or not? Anyone know of any well maintained libraries that does this?
You can write a middleware to check req.headers['user-agent'] or use express-device.
Im no expert but found this php string to work perfectly !
<?php
function isMobile() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
if(isMobile())
print "this is mobile yes";
else
print "this is mobile not true at all";
?>