@browserless/devices

中文文档
14.0.22发布于 2026/10/13MITCommonJS近 30 天下载 2万

Comprehensive device database for browser testing. Emulate mobile phones, tablets, and desktops with accurate viewport and user agent data.

原始使用文档
文档目录10 节
  1. Install
  2. About
  3. What this package does
  4. Device properties
  5. Custom Devices
  6. Fuzzy Device Name Matching
  7. Usage
  8. How it fits in the monorepo
  9. Dependencies
  10. License
browserless browserless

Powered by microlink.io Last version Coverage Status NPM Status

@browserless/devices: A collection of different devices for emulation purposes.

See the devices section on our website for more information.

Install

Using npm:

npm install @browserless/devices --save

About

This package provides a device descriptor library for browser emulation. It extends Puppeteer's built-in device list with additional desktop devices and provides fuzzy matching capabilities for device name resolution.

What this package does

The @browserless/devices package allows you to:

  • Emulate devices by retrieving viewport dimensions, user agent strings, and device capabilities
  • Use fuzzy matching to resolve device names even with typos or case variations
  • Access extended device list that includes desktop devices missing from Puppeteer's defaults

Device properties

Each device descriptor includes:

PropertyDescription
userAgentBrowser user agent string
viewport.widthScreen width in pixels
viewport.heightScreen height in pixels
viewport.deviceScaleFactorDevice pixel ratio (DPR)
viewport.isMobileWhether it's a mobile device
viewport.hasTouchWhether the device has touch support
viewport.isLandscapeWhether the device is in landscape mode

Custom Devices

This package extends Puppeteer's KnownDevices with additional desktop devices. Chrome user agents (including Puppeteer's Android descriptors) are rewritten at runtime to puppeteer.PUPPETEER_REVISIONS.chrome. Safari/iOS descriptors are left unchanged.

The desktop devices below carry no user agent of their own: they supply the viewport, and the platform token inside the user agent comes from the host, Macintosh; Intel Mac OS X 10_15_7 on macOS, X11; Linux x86_64 on Linux, Windows NT 10.0; Win64; x64 on Windows. Worker scopes always report the real host platform, so advertising the host is what keeps navigator.platform and the client hints consistent across them.

DeviceResolutionScale
Macbook Pro 131280 × 8002x
Macbook Pro 151440 × 9002x
Macbook Pro 161536 × 9602x
iMac 211980 × 10801x
iMac 21 4K2048 × 11522x
iMac 24 4.5K4480 × 25201x
iMac 272560 × 14401x
iMac 27 5K2560 × 14402x

Fuzzy Device Name Matching

When lossyDeviceName is enabled (default), the package uses fuzzy matching to resolve device names:

const createGetDevice = require('@browserless/devices')
const getDevice = createGetDevice({ lossyDeviceName: true })

// All of these resolve to "Macbook Pro 13"
getDevice({ device: 'Macbook Pro 13' })
getDevice({ device: 'macbook pro 13' })
getDevice({ device: 'MACBOOK PRO 13' })
getDevice({ device: 'macbook pro' })
getDevice({ device: 'macboo pro' })  // typo still works!

Usage

const createGetDevice = require('@browserless/devices')
const getDevice = createGetDevice()

// Get device by name
const device = getDevice({ device: 'iPhone 13' })
// => { userAgent: '...', viewport: { width: 390, height: 844, ... } }

// Override viewport properties
const customDevice = getDevice({
  device: 'iPad',
  viewport: { isLandscape: true }
})

// Use custom headers
const withHeaders = getDevice({
  headers: { 'user-agent': 'googlebot' }
})

// Access all available devices
console.log(getDevice.deviceDescriptors)

How it fits in the monorepo

This is a standalone utility package with no dependencies on other @browserless/* packages. It's used by:

ConsumerPurpose
@browserless/gotoSets viewport and user agent when navigating to URLs
browserless (core)Exposes getDevice() method on browser contexts

Dependencies

PackagePurpose
didyoumean3Fuzzy string matching for lossy device name resolution
memoize-oneCaches device lookups for performance
require-one-ofAuto-detects puppeteer/puppeteer-core installation

License

@browserless/devices © Microlink, released under the MIT License.
Authored and maintained by Microlink with help from contributors.

The logo has been designed by xinh studio.

microlink.io · GitHub microlinkhq · X @microlinkhq

版本与发布记录

@browserless/devices 共发布 83 个版本,首次发布于 2019/01/28;过去 12 个月发布了 12 个版本。

版本发布日期距今
14.0.22latest2026/10/1326 天前
14.0.02026/10/081 个月前
13.9.222026/09/141 个月前
13.9.142026/09/101 个月前
13.9.102026/09/022 个月前
13.9.02026/08/252 个月前

关于 @browserless/devices 的常见问题

@browserless/devices 是什么?

Comprehensive device database for browser testing. Emulate mobile phones, tablets, and desktops with accurate viewport and user agent data.

如何安装 @browserless/devices?

在项目目录运行 npm install @browserless/devices,或使用 pnpm add / yarn add / bun add。

@browserless/devices 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/browserless__devices 是否存在。

@browserless/devices 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@browserless/devices 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@browserless/devices 可以商用吗?

@browserless/devices 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@browserless/devices 的下载量有多少?

根据 npm 官方下载统计,@browserless/devices 在 2026/10/09 – 2026/11/07 这 30 天内被下载 19,647 次,日均约 655 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@browserless/devices 还在维护吗?

最新版本 14.0.22 发布于 2026/10/13(26 天前);至今共发布 83 个版本,其中过去 12 个月发布了 12 个;首次发布于 2019/01/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。