Skip to content

Adaptive Apps ​

Raw readings tell you what the device is doing. These two APIs tell you what to do about it: one signal for how much work the app should do right now, and one for how capable the hardware is in general.

FunctionReturnsAnswers
getPowerProfile()PowerProfile"Should I hold back right now?" → full / balanced / saver
watchPowerProfile()Promise<UnwatchFn>Same, pushed to you whenever it changes
getDeviceTier()DeviceTier"How much can this device handle?" → low / mid / high

Power profile ​

typescript
import { getPowerProfile, watchPowerProfile } from 'tauri-plugin-device-info-api';

const { profile, reasons } = await getPowerProfile();
// profile: 'saver', reasons: ['lowPowerMode', 'batteryLow']

const unwatch = await watchPowerProfile(({ profile }) => {
  document.documentElement.dataset.power = profile;
});
css
/* Turn off expensive effects when the device is under pressure */
[data-power="saver"] * { animation: none !important; transition: none !important; }
[data-power="saver"] .glass { backdrop-filter: none; }

How the profile is chosen ​

Every active condition implies a profile; the most restrictive one wins, and all active conditions are listed in reasons.

ReasonConditionImplies
lowPowerModeOS power saving is onsaver
thermalCriticalThermal state criticalsaver
thermalSeriousThermal state serioussaver
thermalFairThermal state fairbalanced
batteryCriticalOn battery, ≤ 20%saver
batteryLowOn battery, ≤ 40%balanced

Battery reasons apply only on battery: not charging and not on external power. A laptop on AC that is full, held at a charge limit or "not charging" is on external power (onExternalPower: true), so it never gets a battery reason. When a platform can't tell, the device counts as on battery. A device without a battery (most desktops), or one reporting an unknown or out-of-range level (e.g. the iOS Simulator), gets no battery reason either.

Response ​

json
{
  "profile": "balanced",
  "reasons": ["batteryLow"],
  "batteryLevel": 34,
  "isCharging": false,
  "lowPowerMode": false,
  "thermalState": "nominal",
  "onExternalPower": false
}
FieldTypeDescription
profile'full' | 'balanced' | 'saver'The recommendation
reasonsPowerProfileReason[]Why it isn't full (empty when it is)
batteryLevelnumber?0–100; absent without a battery
isChargingboolean?
lowPowerModeboolean?Absent when the OS doesn't expose it
thermalState'nominal' | 'fair' | 'serious' | 'critical'?Absent on Windows
onExternalPowerboolean?On an AC / USB-C adapter, even when not charging; absent when the OS doesn't say

The raw fields are included so you can apply your own policy if the defaults don't fit.

Platform sources ​

PlatformLow power modeThermal stateExternal power
macOSNSProcessInfo.isLowPowerModeEnabled (macOS 12+)NSProcessInfo.thermalStateIOKit providing power source = AC
iOSProcessInfo.isLowPowerModeEnabledProcessInfo.thermalStateUIDevice.batteryState charging / full
AndroidPowerManager.isPowerSaveModePowerManager.currentThermalStatus (Android 10+)Battery intent EXTRA_PLUGGED
WindowsBattery / Energy Saver (GetSystemPowerStatus)—GetSystemPowerStatus ACLineStatus
LinuxACPI platform profile = low-powerCPU/SoC /sys/class/thermal zones, headroom to critical tripAny online non-battery /sys/class/power_supply

Android's seven thermal levels are mapped onto four: LIGHT/MODERATE → fair, SEVERE → serious, CRITICAL and above → critical. On Linux, a zone within 25 °C / 15 °C / 5 °C of its critical trip point is fair / serious / critical. Only CPU/SoC zones count (x86_pkg_temp, coretemp, k10temp, acpitz, cpu*, soc*, ...), so battery, skin and Wi-Fi sensors with low trip points don't make a cool laptop read as hot; trip points below 80 °C are replaced by a 100 °C default.

watchPowerProfile polls every 5 s by default (minimum 1 s); pass { intervalMs } to change it.

Device tier ​

typescript
import { getDeviceTier } from 'tauri-plugin-device-info-api';

const { tier, score } = await getDeviceTier();
document.documentElement.dataset.tier = tier;

const particleCount = { low: 0, mid: 200, high: 1000 }[tier];

How the tier is scored ​

The score (0–100) is a weighted average of memory, logical cores and peak CPU clock. Each signal is placed on a log scale between a floor and a ceiling for the device's form factor, so a phone is compared with phones and a laptop with laptops:

SignalDesktop rangeMobile rangeWeight (desktop / mobile)
Memory4 – 32 GB2 – 12 GB0.50 / 0.55
Logical cores2 – 164 – 80.30 / 0.15
Peak CPU clock1.5 – 4.5 GHz1.4 – 3.2 GHz0.20 / 0.30

Signals the platform doesn't report (e.g. CPU clock on iOS and Apple Silicon) are left out and the other weights rescaled.

ScoreTier
0 – 29low
30 – 64mid
65 – 100high

On Android, OS hints override the score: a device flagged isLowRamDevice is always low, and a media performance class of 31+ / 33+ guarantees at least mid / high.

Example classifications:

DeviceScoreTier
4 GB dual-core laptop3low
M1 MacBook Air, 8 GB46mid
M3 Pro, 18 GB78high
iPhone 12 (4 GB)43mid
iPhone 15 Pro (8 GB)73high

Response ​

json
{
  "tier": "high",
  "score": 90,
  "hardware": {
    "cpuCores": 15,
    "physicalCores": 15,
    "cpuModel": "Apple M5 Pro",
    "totalMemory": 25769803776,
    "isMobile": false
  }
}
FieldTypeDescription
tier'low' | 'mid' | 'high'Capability class
scorenumber0–100, for finer-grained decisions than the tier
hardware.cpuCoresnumber?Logical cores
hardware.physicalCoresnumber?Physical cores (desktop)
hardware.cpuModelstring?CPU / SoC name or model identifier
hardware.cpuMaxFrequencyMhznumber?Peak clock, where available
hardware.totalMemorynumber?Bytes
hardware.isMobilebooleanWhich scale was used
hardware.isLowRamDeviceboolean?Android only
hardware.mediaPerformanceClassnumber?Android 12+ only

The tier reflects hardware, which doesn't change at runtime, so there's no watch variant. Combine it with the power profile for decisions that depend on both:

typescript
const [{ tier }, { profile }] = await Promise.all([getDeviceTier(), getPowerProfile()]);
const quality = profile === 'saver' ? 'low' : tier;

Rust API ​

Both are also available from Rust, and the scoring functions are public:

rust
use tauri_plugin_device_info::DeviceInfoExt;

let profile = app.device_info().get_power_profile()?;
let tier = app.device_info().get_device_tier()?;

// Pure functions, for your own inputs or tests:
tauri_plugin_device_info::adaptive::power_profile(&battery, &power_state);
tauri_plugin_device_info::adaptive::device_tier(hardware);

Released under the MIT License.