Android-only Expo module to acquire and release a partial WakeLock
npm install expo-wake-lockKeeps the CPU running while your app is active.
Useful for background work, networking, media, or long-running tasks.
Android only.
sh
npm install expo-wake-lock
`Configuration (required)
This module uses a native Android permission and requires a config plugin.
Add the plugin to your Expo config:
`
{
"expo": {
"plugins": ["expo-wake-lock/plugin"]
}
}
`Then regenerate native code:
`
npx expo prebuild
`Usage
`sh
import {
acquireWakeLock,
releaseWakeLock,
isWakeLockHeld,
} from "expo-wake-lock"acquireWakeLock()
// later
releaseWakeLock()
if (isWakeLockHeld()) {
// do something
}
`Platform behavior
Android: Uses PowerManager.PARTIAL_WAKE_LOCK
iOS: No-op (logs a warning)
Web: No-op (logs a warning)
Calls are safely guarded — importing or calling this module will not crash on unsupported platforms.
Permissions
On Android, this module requires:
`xml
``- Wake locks are not reference-counted
- Calling acquire() multiple times has no effect
- Always call release() when finished
- Misuse will drain battery — use carefully
MIT