Skip to content

undeviceЕдиный детектор устройств

Определение устройства, ОС и браузера по заголовкам. Без зависимостей, с TypeScript и поддержкой CDN.

undeviceundevice
ts
import { 
undevice
} from 'undevice'
const {
detect
} =
undevice
()
const
device
=
detect
({
userAgent
:
navigator
.
userAgent
})
device
.
isMobile
device
.
isDesktop
device
.
isWindows
device
.
isChrome
ts
// В примере используется сторонняя библиотека isbot
import { 
isbot
} from 'isbot'
import {
undevice
} from 'undevice'
// Настройка пользовательских флагов const {
detect
} =
undevice
({
isCrawler
:
isbot
,
isRawClient
: ['curl', 'wget'],
}) const
device
=
detect
({
userAgent
:
navigator
.
userAgent
})
device
.
isMobile
device
.
isDesktop
device
.
isWindows
device
.
isChrome
// Использование пользовательских флагов
device
.
isCrawler
device
.
isRawClient

Распространяется по лицензии MIT.
Проект не связан с организацией UnJS.