---
title: Device
summary: Provides device detection based on User-Agent strings.
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/device/class.Device/
---

**Kind:** Class  
**Module:** [device](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/device/)  
**Package:** @fastly/js-compute 4.0.1  
**Since:** 3.10.0  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L9

Provides device detection based on User-Agent strings.

**Note**: Can only be used when processing requests, not during build-time initialization.

## Properties

### name

**Type:** `string | null`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L23

The name of the device, or `null` if no name is known.

### brand

**Type:** `string | null`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L28

The brand of the device, which may be different from the manufacturer.
`null` if no brand is known.

### model

**Type:** `string | null`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L32

The model of the device, or `null` if no model is known.

### hardwareType

**Type:** `string | null`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L42

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.

### isDesktop

**Type:** `boolean | null`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L46

Whether the device is a desktop web browser, or `null` if not known.

### isGameConsole

**Type:** `boolean | null`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L50

Whether the device is a video game console, or `null` if not known.

### isMediaPlayer

**Type:** `boolean | null`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L55

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.

### isMobile

**Type:** `boolean | null`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L59

Whether the device is a mobile phone, or `null` if not known.

### isSmartTV

**Type:** `boolean | null`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L63

Whether the device is a smart TV, or `null` if not known.

### isTablet

**Type:** `boolean | null`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L67

Whether the device is a tablet (like an iPad), or `null` if not known.

### isTouchscreen

**Type:** `boolean | null`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L71

Whether the device's screen is touch sensitive, or `null` if not known.

### isBot

**Type:** `boolean | null`  
**Flags:** read-only, since 3.39.0  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L77

Whether the device is a bot, or `null` if not known.

## Methods

### lookup

**Flags:** static  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L18

```javascript
static lookup(useragent: string): Device | null
```

Look 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**

`Device | null`

**Throws**

- `TypeError` if the provided User-Agent string is empty.

### toJSON

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/device.d.ts#L85

```javascript
toJSON(): Object
```

Returns 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**

`Object`
