How to redirect mobile users to mobile version of Meteor site


#1

have a website www.domain.com and I have designed a new mobile version m.domain.com. But how to detect the mobile device and redirect them to m.domain.com from www.domain.com?

im use meteor 1.4


#2

Hi @channasmcs, if your app is a webapp (not a cordova or native app) that lives on m.domain.com, try inspecting the navigator.userAgent object of your client. This will give you a string like Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev> that you can parse and inspect at will. An easier solution would be to install a meteor package that does that for you (like faisalman:ua-parser-js). You can than see if the user accessing your app is on a mobile device or not. After that, just redirect the user connection (for instance, with window.location = "//m.domain.com")