Skip to content

API Reference

This plugin provides 5 getters to read device information, plus a reactive watch API to subscribe to changes.

Functions Overview

FunctionDescription
getDeviceInfo()Device identification and hardware info
getBatteryInfo()Battery status and health
getNetworkInfo()Network connection details
getStorageInfo()Storage capacity information
getDisplayInfo()Display properties and capabilities
watch*()Subscribe to changes for any of the above kinds

Quick Reference

typescript
import { 
  getDeviceInfo,    // → DeviceInfoResponse
  getBatteryInfo,   // → BatteryInfo
  getNetworkInfo,   // → NetworkInfo
  getStorageInfo,   // → StorageInfo
  getDisplayInfo,   // → DisplayInfo

  // Reactive watch API → Promise<UnwatchFn>
  watchDevice,
  watchBattery,
  watchNetwork,
  watchStorage,
  watchDisplay
} from 'tauri-plugin-device-info-api';

Type Exports

All response types are exported for TypeScript users:

typescript
import type { 
  DeviceInfoResponse, 
  BatteryInfo, 
  NetworkInfo, 
  StorageInfo, 
  DisplayInfo,
  WatchOptions,
  UnwatchFn
} from 'tauri-plugin-device-info-api';

Naming Convention

The JavaScript API uses camelCase for all property names:

Rust (internal)JavaScript
is_chargingisCharging
ip_addressipAddress
mac_addressmacAddress
total_spacetotalSpace
free_spacefreeSpace
storage_typestorageType
scale_factorscaleFactor
refresh_raterefreshRate

Released under the MIT License.