Skip to main content

expo-keep-awake

Version: 55.0.3 Provides a React component that prevents the screen from sleeping when rendered. It also exposes static methods to control the behavior imperatively.

Installation

Usage

Component-Based

Hook-Based

Imperative API

API Reference

Component

React.Component
Renders a component that prevents screen from sleeping
Automatically activates when mounted and deactivates when unmounted.

Hook

(tag?: string) => void
Hook that keeps screen awake while component is mounted
Optional tag parameter allows multiple independent keep-awake instances.

Methods

(tag?: string) => void
Activates keep-awake mode
(tag?: string) => void
Deactivates keep-awake mode

Examples

Video Player

Conditional Keep Awake

Imperative Control

Multiple Instances with Tags

Reading Mode

Camera Preview

TypeScript

Platform Support

How It Works

  • iOS: Sets UIApplication.shared.isIdleTimerDisabled = true
  • Android: Adds FLAG_KEEP_SCREEN_ON to the window
  • Web: Uses Wake Lock API or NoSleep.js fallback

Best Practices

  1. Use Component/Hook: Prefer <KeepAwake /> or useKeepAwake() for automatic cleanup
  2. Clean Up: Always deactivate when no longer needed to save battery
  3. Use Tags: Use unique tags for multiple independent instances
  4. Conditional Usage: Only activate when actually needed (e.g., during video playback)
  5. User Control: Consider letting users disable keep-awake in settings
Keeping the screen on drains battery faster. Only use when necessary for user experience.

Resources