Device
Provides device detection based on User-Agent strings.
Note: Can only be used when processing requests, not during build-time initialization.
Properties
The name of the device, or null if no name is known.
The brand of the device, which may be different from the manufacturer.
null if no brand is known.
The model of the device, or null if no model is known.
A string representation of the device's primary platform hardware,
or null if not known.
The most commonly used device types are also identified via boolean properties. Because a device may have multiple device types and this property only has the primary type, we recommend using the boolean properties for logic and this string representation for logging.
Whether the device is a desktop web browser, or null if not known.
Whether the device is a video game console, or null if not known.
Whether the device is a media player (like Blu-ray players, iPod
devices, and smart speakers such as Amazon Echo), or null if not known.
Whether the device is a mobile phone, or null if not known.
Whether the device is a smart TV, or null if not known.
Whether the device is a tablet (like an iPad), or null if not known.
Whether the device's screen is touch sensitive, or null if not known.
Whether the device is a bot, or null if not known.
Methods
static lookup(useragent: string): Device | nullLook up the data associated with a particular User-Agent string.
If there is data associated with the User-Agent, a Device instance is returned.
Otherwise, null is returned.
Parameters
- useragent: string
The User-Agent string to look up.
Returns
Throws
TypeErrorif the provided User-Agent string is empty.
toJSON
View sourceReturns a JSON representation of the Device object.
To get a JSON string, you can use JSON.stringify(device) directly;
it will call toJSON() automatically.
Returns