Getting Started
Copy a setup prompt with the install steps and the full markdown guide for this plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-device-info`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/device-info/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Compatibility
Section titled “Compatibility”@capgo/capacitor-device-info requires Capacitor 8 or later (@capacitor/core >=8.0.0).
Install
Section titled “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/capgo-skills --skill capacitor-pluginsThen use the following prompt:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-device-info` plugin in my project.For a manual setup, install the package and sync the native projects:
npm install @capgo/capacitor-device-infonpx cap syncImport
Section titled “Import”import { DeviceInfo } from '@capgo/capacitor-device-info';Read one snapshot
Section titled “Read one snapshot”const snapshot = await DeviceInfo.getInfo();
console.log(snapshot.cpu.cores);console.log(snapshot.memory.usedPercent);console.log(snapshot.storage.freeBytes);console.log(snapshot.sensors?.pressureHpa);cpu.usagePercent is delta-based. The first native sample can omit it; call getInfo() again later or use monitoring to receive populated CPU usage after the second sample.
Stream updates
Section titled “Stream updates”const handle = await DeviceInfo.addListener('deviceInfoUpdate', (sample) => { console.log(sample.sequence, sample.elapsedMs); console.log(sample.cpu.usagePercent); console.log(sample.sensors?.readings);});
const session = await DeviceInfo.startMonitoring({ intervalMs: 1000, emitImmediately: true,});
console.log(session.intervalMs, session.startedAt);Monitoring behavior
Section titled “Monitoring behavior”intervalMsdefaults to1000milliseconds. Values below250milliseconds are clamped to250.emitImmediatelydefaults totrue.- Set
durationMsorsampleCountto stop monitoring automatically. - Calling
startMonitoring()while monitoring is active restarts the session with the new options. - Every
deviceInfoUpdateincludes a one-basedsequence, the session’sstartedAttimestamp, andelapsedMs.
Stop updates and remove listeners
Section titled “Stop updates and remove listeners”await DeviceInfo.stopMonitoring();await handle.remove();
// Or remove every listener registered on this plugin:await DeviceInfo.removeAllListeners();Check monitoring state
Section titled “Check monitoring state”const state = await DeviceInfo.isMonitoring();
if (state.monitoring) { console.log(state.samplesEmitted);}Onboard sensor fields
Section titled “Onboard sensor fields”const { sensors, cpu, gpu } = await DeviceInfo.getInfo();
console.log(cpu.temperatureCelsius);console.log(gpu?.temperatureCelsius);console.log(sensors?.batteryTemperatureCelsius);console.log(sensors?.ambientTemperatureCelsius);console.log(sensors?.relativeHumidityPercent);console.log(sensors?.pressureHpa);console.log(sensors?.illuminanceLux);console.log(sensors?.proximityDistanceCm);console.log(sensors?.availableSensors);Sensor fields are optional. They are present only when the device, OS, and app sandbox expose that metric.
Platform notes
Section titled “Platform notes”- iOS requires no permissions for the exposed metrics. It reports CoreMotion sensor availability but not raw CPU or GPU temperature.
- Android requires no permissions for the exposed metrics. CPU and GPU temperatures are best-effort thermal-zone reads.
- Web support is best effort and reports empty onboard sensor arrays because browsers do not expose native device sensors consistently.
API reference
Section titled “API reference”| Method | Returns | Notes |
|---|---|---|
getInfo() | Promise<DeviceInfoSnapshot> | Reads one snapshot. |
startMonitoring(options?) | Promise<StartMonitoringResult> | Starts periodic snapshots, or restarts an active session with new options. |
stopMonitoring() | Promise<StopMonitoringResult> | Stops the active session. |
isMonitoring() | Promise<MonitoringState> | Returns current session state. |
addListener('deviceInfoUpdate', listener) | Promise<PluginListenerHandle> | Registers a periodic snapshot listener. |
removeAllListeners() | Promise<void> | Removes every listener registered on the plugin. |
getPluginVersion() | Promise<PluginVersionResult> | Reads the native plugin version. |
PluginListenerHandle is provided by Capacitor and has remove() for removing that individual listener.
Snapshot types
Section titled “Snapshot types”interface CpuInfo { cores: number; activeCores?: number; architecture?: string; model?: string; usagePercent?: number | null; maxFrequencyHz?: number; temperatureCelsius?: number;}
interface MemoryInfo { totalBytes?: number; freeBytes?: number; usedBytes?: number; usedPercent?: number; appUsedBytes?: number; appLimitBytes?: number; lowMemory?: boolean; pressure?: 'normal' | 'warning' | 'critical' | 'unknown';}
interface StorageInfo { totalBytes?: number; freeBytes?: number; usedBytes?: number; usedPercent?: number;}
interface GpuInfo { api?: 'metal' | 'opengl' | 'webgl' | 'unknown'; vendor?: string; renderer?: string; version?: string; maxTextureSize?: number; temperatureCelsius?: number;}
type ThermalState = 'nominal' | 'fair' | 'serious' | 'critical' | 'unknown';
interface DeviceInfoSnapshot { timestamp: number; platform: 'ios' | 'android' | 'web'; cpu: CpuInfo; memory: MemoryInfo; storage: StorageInfo; gpu?: GpuInfo; thermalState?: ThermalState; lowPowerMode?: boolean; sensors?: OnboardSensorsInfo;}Sizes are bytes, maxFrequencyHz is hertz, and temperature values are Celsius. usagePercent can be null until the platform has enough samples to calculate it.
Sensor types
Section titled “Sensor types”interface OnboardSensorDescriptor { type: string; name?: string; vendor?: string; platformType?: number; maximumRange?: number; resolution?: number; powerMilliamp?: number; minDelayMicroseconds?: number; wakeUp?: boolean;}
interface OnboardSensorReading { type: string; unit: string; value: number; name?: string; timestamp?: number;}
interface OnboardSensorsInfo { availableSensors?: OnboardSensorDescriptor[]; readings?: OnboardSensorReading[]; batteryTemperatureCelsius?: number; ambientTemperatureCelsius?: number; relativeHumidityPercent?: number; pressureHpa?: number; illuminanceLux?: number; proximityDistanceCm?: number;}Sensor-reading timestamps are Unix epoch milliseconds. Common units are Celsius, percent, hPa, lux, and centimeters.
Monitoring types
Section titled “Monitoring types”interface MonitoringOptions { intervalMs?: number; durationMs?: number; sampleCount?: number; emitImmediately?: boolean;}
interface StartMonitoringResult { monitoring: boolean; intervalMs: number; startedAt: number;}
interface StopMonitoringResult { monitoring: boolean;}
interface MonitoringState { monitoring: boolean; intervalMs?: number; startedAt?: number; samplesEmitted?: number;}
interface DeviceInfoUpdate extends DeviceInfoSnapshot { sequence: number; startedAt: number; elapsedMs: number;}
interface PluginVersionResult { version: string;}startedAt, timestamp, and elapsedMs are milliseconds. sequence starts at 1 for each monitoring session.
Source of truth
Section titled “Source of truth”This reference follows the public API in the plugin’s src/definitions.ts. Update this page when that source changes.
Keep going from Getting Started
Section titled “Keep going from Getting Started”If you are using Getting Started for device diagnostics, connect it with @capgo/capacitor-device-info for the overview, Using @capgo/capacitor-device-info for the tutorial page, @capgo/capacitor-barometer for focused pressure readings, and @capgo/capacitor-light-sensor for focused light sensor readings.