---
title: "Recipe: the battery, the network and Low Power Mode"
description: "@exact/device reads the battery, the network type, Save Data, Low Power Mode and the thermal state with no permission, and the app decides what to change."
modificationDate: "2026-11-24"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: the battery, the network and Low Power Mode

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/device: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

`@exact/device` (LLP 1133.031) reports three live facts without permission:

```prompt Use the battery, the network and Low Power Mode
Make the Exact app in this folder read the battery, the network and Low Power Mode, and use less when the person or the device asks. Use https://github.com/expo/exact/blob/main/docs/recipes/device.md as the source for each step. The Exact checkout has the same page at docs/recipes/device.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me. Find the Exact checkout (the folder with scripts/exact.mjs); if you cannot find it, ask me where it is.
2. If I did not say what the app changes for each fact, propose it (for example, stop an animation in Low Power Mode, or defer an upload under Save Data) and ask me.
3. Install the package: `bun <exact2>/scripts/exact.mjs add device .`. None of the three facts asks permission.
4. In app.contract, read `getBattery()`, `connection()` and `powerState()` as resources, each with a placeholder no answer can be (`level=-1`, `type="unknown"`), so a failed read draws what the app draws without the fact. `powerState()` fails on the web.
5. What the person presses wins over the device: keep the person's choice in a state, and let the device decide only while there is none. In data code, read the same sources as Promises.
6. Add a Linux test to app.test.contract using `prefer extension device.powerState={"lowPowerMode":true}`, then `prefer extension device.powerState=clear`. Settle and check the app's reaction after each step. Add a case where the person already chose and check that their choice still wins.
7. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 8) and report it; do not keep trying.
8. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
9. Tell me which facts the app reads, what it changes for each, and what the tests and verify reported.
```

- `getBattery()`: the Battery Status API's `level` (0 to 1, in hundredths)
  and `charging` (false only while discharging). A Mac mini, Apple TV or iOS simulator reports the API’s batteryless default, `level` 1 and `charging` true.
- `connection()`: the Network Information API's `type` (`wifi`,
  `cellular`, `ethernet`, `none`, `other`, `unknown`, …) and Save Data's
  `saveData`, the person's own request to use less data: Low Data Mode on
  Apple, Data Saver on Android.
- `powerState()`: `lowPowerMode` (Low Power Mode, Battery Saver, Energy
  Saver) and `thermalState` (`nominal`, `fair`, `serious`, `critical`).
  No browser has either, so on the web it fails `NotSupportedError`.

Give each resource a placeholder no answer can be, so a failed read (Safari
and Firefox have neither web API) draws what the app draws without the
fact:

```text
use getBattery, connection, powerState, BatteryManager, NetworkInformation, PowerState from "@exact/device"

component App
  state skyChoice = ""   // "", "play" or "pause": the person's, once pressed
  resource battery = getBattery() as shape BatteryManager else empty(level=-1)
  resource network = connection() as shape NetworkInformation else empty(type="unknown")
  resource power = powerState() as shape PowerState else empty()
  derive hot = match power.thermalState { case some(t) => t == "serious" or t == "critical", case none => false }
  derive animated = skyChoice == "play" or (skyChoice == "" and not (power.lowPowerMode or hot))
  derive saving = power.lowPowerMode or network.saveData
  action toggleMotion
    skyChoice = animated ? "pause" : "play"
  view
    column
      if battery.level >= 0
        text `${round(battery.level * 100)}%`
```

What to do with the facts is the app's. Apple asks an app in Low Power Mode
to "reduce the use of animations, lower frame rates, … disable syncs"
([Energy Efficiency Guide](https://developer.apple.com/library/archive/documentation/Performance/Conceptual/EnergyGuide-iOS/LowPowerMode.html)).
What the person presses wins over the device: a sky they pressed play on
keeps playing.

Read connectivity from `exactPage().onLine` and GPU capability from `exactViewport().gpuTier`.

Data code reads the same sources as Promises, as a wake does to decide
whether to defer an upload:

```ts
import { connection, powerState } from '@exact/device';
const [net, power] = await Promise.all([connection({}), powerState({}).catch(() => null)]);
if (net.saveData || power?.lowPowerMode) return { deferred: true };
```

Under the agent the declaration supplies a full battery and network type
`unknown`. In a Linux test, check the app's reaction after each change:

```contract-test
test "Low Power Mode" on linux
  prefer extension device.powerState={"lowPowerMode":true}
  clock settle
  expect state power.lowPowerMode == true
  prefer extension device.powerState=clear
  clock settle
  expect state power.lowPowerMode == false
```
