UADetect Componets
Overview
Components
You can think of a componet as a function, each of which return an interaction with the navigator
, in a more readable form. Each of the componets are self-contained, and can be used in any project.
Methods
You can think of a method as a way of 're-calling" the functions that return components. The method(s) that return componets are all named in the format get(ComponentName)
and can be imported in the same way you would import a component.
Alternatively, you can create your own psuedo-components
by writing variables to are equal to the returns on the methods. For example.
import { getDeviceType } from 'uadetect'const someCustomNameForAComponent = getDeviceType();if (someCustomNameForAComponent === "mobile") { // do something}
Alternate
Alternatively, you can call the UADetect
object, and (hopefully), your IDE will autocomplete the methods and components returned on them. Let's take a look at an example:
// Import the objectimport { UADetect } from 'uadetect'// Example calling a methodUADetect.detectDeviceType()// Example using a propertyconsole.log(UADetect.deviceType);
As an alternate to that alternate, there is also a uaDetect
class that you can instantiate, whhich has all the methods and properties on it as well. Let's take a look at another example.
// Import the classimport { uaDetect } from 'uadetect'// Create a new instantiation of the classconst UAD = new uaDetect()// Example calling a methodUAD.detectDeviceType();// Example using a propertyconsole.log(UAD.deviceType)
Components
NOTE:
Click any of them to go to their individual documentation.
browser
browserOnlineStatus
cookieStatus
currentUA
finiteDeviceType
deviceMemory
deviceType
doNotTrackStatus
language
maxTouchPoints
media
orientationIsLandscape
OS
PDFviewerStatus
processorCores
robotStatus
Methods
vibrate
canShareData
getMedia
registerServiceWorker
getScreenOrientation
getDeviceType
getFiniteMobileDeviceType
getCurrentUA
getCookies
getBrowser
browserSpecificSupportCores
getMaxTouchPoints
getOS
getterForNavigator
getBrowserIsOnline
getPDF
getBots
getLang
getMemory