1const getDeviceType = () => {
2 const ua = navigator.userAgent;
3 if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(ua)) {
4 return "tablet";
5 }
6 if (
7 /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(
8 ua
9 )
10 ) {
11 return "mobile";
12 }
13 return "desktop";
14};
15