Skip to content

Input and result ​

detect(options) accepts the options below. Pass {} without headers or a User-Agent to get an unknown device type.

ts
type UndeviceOptions = Readonly<{
  headers?: RequestHeaders;
  userAgent?: string;
}>;
OptionTypeDefaultDescription
headersRequestHeadersundefinedRequest headers. Accepts a standard Headers instance or a plain record, including Node.js request headers.
userAgentstringFrom headersUsed instead of the user-agent header value. Also supports standalone UA detection.

Result ​

UndeviceResult contains the following built-in boolean flags:

GroupFlags
DeviceisMobile, isTablet, isDesktop, isUnknown
CombinedisMobileOrTablet, isDesktopOrTablet
OSisIos, isAndroid, isWindows, isMacOS, isLinux, isApple
BrowserisChrome, isFirefox, isSafari, isEdge, isSamsung

isUnknown is true when the input does not resolve to a device type. Custom flags are added to the same result object.

Released under the MIT License.