If you want to detect with javascript if a user is using a mobile device, here is one way you can do it:
const agent = (device) => navigator.userAgent.indexOf(device) > -1;
const isDevice = {
iphone: () => agent('iPhone'),
ipod: () => agent('iPod'),
ipad: () => agent('iPad'),
android: () => agent('Android'),
blackberry: () => agent('BlackBerry'),
opera: () => agent('Opera Mini'),
windows: () => agent('IEMobile'),
};
if(isDevice.iphone()) {
console.log('Iphone device detected');
// Iphone device detected
}