подключите такой модуль к проекту:
const appleDevice = /iP(hone|od|ad)/;
const applePhone = /iPhone/i;
const appleIPod = /iPod/i;
const appleTablet = /iPad/i;
const androidPhone = /(?=.*\bAndroid\b)(?=.*\bMobile\b)/i;
const androidTablet = /Android/i;
const windowsPhone = /Windows Phone/i;
const windowsTablet = /(?=.*\bWindows\b)(?=.*\bARM\b)/i;
const otherBlackberry = /BlackBerry/i;
const otherOpera = /Opera Mini/i;
const otherFirefox = /(?=.*\bFirefox\b)(?=.*\bMobile\b)/i;
const sevenInch = /(?:Nexus 7|BNTV250|Kindle Fire|Silk|GT-P1000)/i;
function match(regex, target = navigator.userAgent) {
return regex.test(target);
}
export const isAppleDevice = match(applePhone) || match(appleIPod) || match(appleTablet) || match(appleDevice, navigator.platform);
export const isAndroidDevice = match(androidPhone) || match(androidTablet);
export const isWindowsDevice = match(windowsPhone) || match(windowsTablet);
export const isOtherDevice = match(otherBlackberry) || match(otherOpera) || match(otherFirefox);
export const isSevenInch = match(sevenInch);
export const isMobileDevice = isAppleDevice || isAndroidDevice || isWindowsDevice || isOtherDevice || isSevenInch;
export const isEmulator = isMobileDevice && !isWindowsDevice && (match(/Mac/, navigator.platform) || match(/Win32/, navigator.platform));
далее импортируйте нужный флаг, и проверяйте через if