@capgo/capacitor-device-info

中文文档
8.0.16发布于 2026/10/15MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 6.4万

Capacitor plugin for reading CPU, memory, GPU, storage, and onboard sensor metrics.

原始使用文档
文档目录20 节
  1. ➡️ Get started for free
  2. Features
  3. What You Can Read
  4. Sensor Coverage
  5. Common Use Cases
  6. Compatibility
  7. Install
  8. Usage
  9. Platform Notes
  10. Example App
  11. API
  12. getInfo()
  13. startMonitoring(...)
  14. stopMonitoring()
  15. isMonitoring()
  16. addListener('deviceInfoUpdate', ...)
  17. removeAllListeners()
  18. getPluginVersion()
  19. Interfaces
  20. Type Aliases

@capgo/capacitor-device-info

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-device-info in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-device-info to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

Production-ready Capacitor plugin for device diagnostics, support screens, QA tools, and in-app performance dashboards. Read CPU, memory, GPU, storage, thermal, low-power-mode, and onboard sensor data from iOS, Android, and Web with one snapshot call or a live interval stream.

@capgo/capacitor-device-info example app streaming CPU, memory, storage, GPU, and onboard sensor metrics

Features

  • One API for instant snapshots and live monitoring streams.
  • No runtime permissions for the metrics currently exposed.
  • Built for support/debug dashboards: identify low memory, storage pressure, low power mode, thermal state, GPU renderer, and hardware sensor availability.
  • Listener-first streaming for charts: deviceInfoUpdate emits CPU, memory, storage, GPU, thermal, and sensor snapshots on a configurable interval.
  • Auto-stop streams by durationMs or sampleCount.
  • Onboard sensor catalog with common readings when hardware exposes them: battery temperature, ambient temperature, relative humidity, pressure, light, and proximity.
  • Native implementations: Metal, Mach, and CoreMotion availability on iOS; ActivityManager, StatFs, /proc, OpenGL ES, SensorManager, and thermal zones on Android.

What You Can Read

AreaData
CPUCore count, active cores, architecture, model, usage percent, max frequency, Android best-effort CPU temperature
MemoryTotal/free/used bytes, used percent, app heap usage/limit, low-memory flag, pressure state
StorageTotal/free/used bytes and used percent for the app data volume
GPUAPI, vendor, renderer, version, max texture size, Android best-effort GPU temperature
PowerLow power mode / battery saver state
ThermalPlatform thermal state: nominal, fair, serious, critical, or unknown
SensorsFull onboard sensor list plus sampled readings for supported environmental/proximity sensors
Stream metadataSequence number, stream start timestamp, elapsed milliseconds

Sensor Coverage

ReadingiOSAndroidWeb
Sensor availability listCoreMotion sensor availabilitySensorManager full sensor listEmpty fallback
CPU/GPU temperatureNot exposed by public iOS APIsBest-effort thermal-zone readsNot exposed
Battery temperatureNot exposed by public iOS APIsACTION_BATTERY_CHANGEDNot exposed
Ambient temperatureNot exposedSampled when TYPE_AMBIENT_TEMPERATURE existsNot exposed
Relative humidityNot exposedSampled when TYPE_RELATIVE_HUMIDITY existsNot exposed
PressureBarometer availabilitySampled when TYPE_PRESSURE existsNot exposed
LightNot exposedSampled when TYPE_LIGHT existsNot exposed
ProximityNot exposedSampled when TYPE_PROXIMITY existsNot exposed

Sensor data is onboard-only. This plugin does not call weather services or fetch outside temperature/humidity from the network.

Common Use Cases

  • Add a diagnostics panel to support tickets.
  • Stream device metrics into an in-app performance graph.
  • Detect low-memory or low-storage conditions before heavy work.
  • Show hardware/GPU details when debugging device-specific rendering bugs.
  • Log thermal and low-power state around slow sessions.
  • Discover available sensors before enabling sensor-heavy features.

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*Yes
v7.*.*v7.*.*On demand
v6.*.*v6.*.*On demand

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-device-info` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-device-info
npx cap sync

Usage

import { DeviceInfo } from '@capgo/capacitor-device-info';

const snapshot = await DeviceInfo.getInfo();
console.log(snapshot.cpu.cores, snapshot.memory.usedPercent);

const handle = await DeviceInfo.addListener('deviceInfoUpdate', (sample) => {
  console.log(sample.sequence, sample.cpu.usagePercent, sample.memory.usedPercent);
});

await DeviceInfo.startMonitoring({
  intervalMs: 1000,
  durationMs: 60_000,
  emitImmediately: true,
});

await DeviceInfo.stopMonitoring();
await handle.remove();

CPU usage is calculated from deltas, so the first native sample may omit cpu.usagePercent. Periodic monitoring fills it after the second sample when the platform exposes CPU ticks.

Platform Notes

  • iOS requires no permissions for the metrics exposed here. GPU data comes from Metal, CPU and memory data comes from Mach APIs, and sensor availability comes from CoreMotion checks. iOS public APIs do not expose raw CPU/GPU temperature.
  • Android requires no permissions. GPU data is queried from a short-lived OpenGL ES context and then cached. CPU/GPU temperatures are best-effort thermal-zone reads and may be omitted on restricted devices.
  • Web support is best effort. Browser APIs expose CPU cores, storage quota, JS heap on Chromium, and WebGL GPU strings when allowed.

Example App

The example-app/ folder links to the plugin with file:.. and includes an interval listener chart.

cd example-app
npm install
npm run start

API

Capacitor plugin contract for reading device CPU, memory, GPU, storage, and onboard sensor metrics.

getInfo()

getInfo() => Promise<DeviceInfoSnapshot>

Read one CPU, memory, GPU, storage, thermal, and onboard sensor snapshot.

Returns: Promise<DeviceInfoSnapshot>

Since: 8.0.0


startMonitoring(...)

startMonitoring(options?: MonitoringOptions | undefined) => Promise<StartMonitoringResult>

Start periodic device snapshots.

Listen to deviceInfoUpdate to receive samples. Calling this while monitoring is already active restarts monitoring with the new options.

ParamType
optionsMonitoringOptions

Returns: Promise<StartMonitoringResult>

Since: 8.0.0


stopMonitoring()

stopMonitoring() => Promise<StopMonitoringResult>

Stop periodic device snapshots.

Returns: Promise<StopMonitoringResult>

Since: 8.0.0


isMonitoring()

isMonitoring() => Promise<MonitoringState>

Return current periodic monitoring state.

Returns: Promise<MonitoringState>

Since: 8.0.0


addListener('deviceInfoUpdate', ...)

addListener(eventName: 'deviceInfoUpdate', listenerFunc: (event: DeviceInfoUpdate) => void) => Promise<PluginListenerHandle>

Listen for periodic device snapshots.

ParamTypeDescription
eventName'deviceInfoUpdate'Only the deviceInfoUpdate event is supported.
listenerFunc(event: DeviceInfoUpdate) => voidCallback invoked with each snapshot.

Returns: Promise<PluginListenerHandle>

Since: 8.0.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners that have been registered on the plugin.

Since: 8.0.0


getPluginVersion()

getPluginVersion() => Promise<PluginVersionResult>

Get the native Capacitor plugin version.

Returns: Promise<PluginVersionResult>

Since: 8.0.0


Interfaces

DeviceInfoSnapshot

Instant device snapshot returned by {@link DeviceInfoPlugin.getInfo}.

PropTypeDescriptionSince
timestampnumberSnapshot timestamp as Unix epoch milliseconds.8.0.0
platform'ios' | 'android' | 'web'Platform implementation that produced the snapshot.8.0.0
cpuCpuInfoCPU information and usage.8.0.0
memoryMemoryInfoMemory information and usage.8.0.0
storageStorageInfoStorage information and usage.8.0.0
gpuGpuInfoGPU information when the platform exposes it.8.0.0
thermalStateThermalStateThermal state when the platform exposes it.8.0.0
lowPowerModebooleanLow-power mode state when the platform exposes it.8.0.0
sensorsOnboardSensorsInfoOnboard sensor availability and readings.8.0.0

CpuInfo

CPU snapshot for the current device.

All frequency values are reported in hertz. usagePercent is null when a platform needs at least two samples to calculate CPU usage.

PropTypeDescriptionSince
coresnumberTotal logical CPU cores visible to the app.8.0.0
activeCoresnumberLogical CPU cores currently active, when the platform exposes it.8.0.0
architecturestringCPU architecture, for example arm64 or x86_64.8.0.0
modelstringCPU or SoC model identifier when available.8.0.0
usagePercentnumber | nullSystem CPU usage from 0 to 100.8.0.0
maxFrequencyHznumberHighest CPU frequency exposed by the platform.8.0.0
temperatureCelsiusnumberCPU temperature in Celsius when the platform exposes an onboard thermal sensor. Android reads this as a best-effort value from device thermal zones. iOS does not expose raw CPU temperature through public APIs.8.0.0

MemoryInfo

Memory snapshot for the current device and app process.

All size values are reported in bytes.

PropTypeDescriptionSince
totalBytesnumberTotal physical memory on the device.8.0.0
freeBytesnumberMemory available to the system.8.0.0
usedBytesnumberMemory currently used by the system.8.0.0
usedPercentnumberMemory usage from 0 to 100.8.0.0
appUsedBytesnumberMemory used by the current app process.8.0.0
appLimitBytesnumberHeap limit visible to the current app process.8.0.0
lowMemorybooleanWhether the OS currently reports low-memory pressure.8.0.0
pressure'normal' | 'warning' | 'critical' | 'unknown'Platform memory pressure label.8.0.0

StorageInfo

Storage snapshot for the app data volume.

All size values are reported in bytes.

PropTypeDescriptionSince
totalBytesnumberTotal bytes on the app data volume.8.0.0
freeBytesnumberFree bytes on the app data volume.8.0.0
usedBytesnumberUsed bytes on the app data volume.8.0.0
usedPercentnumberStorage usage from 0 to 100.8.0.0

GpuInfo

GPU snapshot for the primary graphics device.

PropTypeDescriptionSince
api'unknown' | 'metal' | 'opengl' | 'webgl'Graphics API used to query the GPU.8.0.0
vendorstringGPU vendor when available.8.0.0
rendererstringGPU renderer or model name when available.8.0.0
versionstringGraphics API version string when available.8.0.0
maxTextureSizenumberMaximum texture size reported by the graphics API.8.0.0
temperatureCelsiusnumberGPU temperature in Celsius when the platform exposes an onboard thermal sensor. Android reads this as a best-effort value from device thermal zones. iOS does not expose raw GPU temperature through public APIs.8.0.0

OnboardSensorsInfo

Onboard sensors snapshot.

This only reports hardware sensors exposed by the device or operating system. It does not fetch weather data or any external temperature/humidity source.

PropTypeDescriptionSince
availableSensorsOnboardSensorDescriptor[]Sensors available to the app.8.0.0
readingsOnboardSensorReading[]Instant sensor readings captured for common environmental sensors.8.0.0
batteryTemperatureCelsiusnumberBattery temperature in Celsius when available.8.0.0
ambientTemperatureCelsiusnumberAmbient air temperature from an onboard sensor in Celsius when available.8.0.0
relativeHumidityPercentnumberRelative humidity from an onboard sensor as a percentage when available.8.0.0
pressureHpanumberAtmospheric pressure from an onboard barometer in hectopascals when available.8.0.0
illuminanceLuxnumberAmbient light from an onboard light sensor in lux when available.8.0.0
proximityDistanceCmnumberProximity distance from an onboard proximity sensor in centimeters when available.8.0.0

OnboardSensorDescriptor

Description of an onboard hardware sensor exposed by the platform.

PropTypeDescriptionSince
typestringStable sensor type label, for example pressure, ambientTemperature, or accelerometer.8.0.0
namestringPlatform sensor name when available.8.0.0
vendorstringSensor vendor when available.8.0.0
platformTypenumberAndroid sensor type id when available.8.0.0
maximumRangenumberMaximum sensor range when available.8.0.0
resolutionnumberSensor resolution when available.8.0.0
powerMilliampnumberSensor power draw in milliamps when available.8.0.0
minDelayMicrosecondsnumberMinimum sensor delay in microseconds when available.8.0.0
wakeUpbooleanWhether this is a wake-up sensor when available.8.0.0

OnboardSensorReading

Instant onboard sensor reading.

PropTypeDescriptionSince
typestringStable sensor type label.8.0.0
unitstringHuman-readable unit, for example celsius, percent, hPa, lux, or cm.8.0.0
valuenumberSensor value.8.0.0
namestringPlatform sensor name when available.8.0.0
timestampnumberReading timestamp as Unix epoch milliseconds.8.0.0

StartMonitoringResult

Result returned when monitoring starts.

PropTypeDescriptionSince
monitoringbooleanWhether monitoring is active.8.0.0
intervalMsnumberEffective interval in milliseconds.8.0.0
startedAtnumberMonitoring start timestamp as Unix epoch milliseconds.8.0.0

MonitoringOptions

Options used to start periodic device snapshots.

PropTypeDescriptionSince
intervalMsnumberTime between samples in milliseconds. Values below 250ms are clamped to 250ms to avoid excessive native work. Defaults to 1000ms.8.0.0
durationMsnumberStop automatically after this duration in milliseconds.8.0.0
sampleCountnumberStop automatically after this number of emitted samples.8.0.0
emitImmediatelybooleanEmit one sample immediately when monitoring starts. Defaults to true.8.0.0

StopMonitoringResult

Result returned by {@link DeviceInfoPlugin.stopMonitoring}.

PropTypeDescriptionSince
monitoringbooleanWhether monitoring remains active after the stop request.8.0.0

MonitoringState

Current monitoring state.

PropTypeDescriptionSince
monitoringbooleanWhether monitoring is active.8.0.0
intervalMsnumberEffective interval in milliseconds when monitoring is active.8.0.0
startedAtnumberMonitoring start timestamp as Unix epoch milliseconds.8.0.0
samplesEmittednumberNumber of samples emitted by the active monitoring session.8.0.0

PluginListenerHandle

PropType
remove() => Promise<void>

DeviceInfoUpdate

Periodic event payload emitted while monitoring is active.

PropTypeDescriptionSince
sequencenumberOne-based sample sequence for the active monitoring session.8.0.0
startedAtnumberMonitoring start timestamp as Unix epoch milliseconds.8.0.0
elapsedMsnumberElapsed milliseconds since monitoring started.8.0.0

PluginVersionResult

Plugin version payload.

PropTypeDescriptionSince
versionstringVersion identifier returned by the platform implementation.8.0.0

Type Aliases

ThermalState

Thermal state reported by the platform.

'nominal' | 'fair' | 'serious' | 'critical' | 'unknown'

版本与发布记录

@capgo/capacitor-device-info 共发布 17 个版本,首次发布于 2026/05/30;过去 12 个月发布了 17 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.0.16latest2026/10/1525 天前
8.0.152026/10/1327 天前
8.0.142026/10/091 个月前
8.0.132026/10/081 个月前
8.0.122026/10/081 个月前
8.0.112026/09/161 个月前

关于 @capgo/capacitor-device-info 的常见问题

@capgo/capacitor-device-info 是什么?

Capacitor plugin for reading CPU, memory, GPU, storage, and onboard sensor metrics.

如何安装 @capgo/capacitor-device-info?

在项目目录运行 npm install @capgo/capacitor-device-info,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-device-info 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-device-info 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-device-info 可以商用吗?

@capgo/capacitor-device-info 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-device-info 的下载量有多少?

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

@capgo/capacitor-device-info 还在维护吗?

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