This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

Expo KeepAwake iconExpo KeepAwake

A React component that prevents the screen from sleeping when rendered.

Android
iOS
tvOS
Web
Included in Expo Go
Recommended version:
~56.0.3

expo-keep-awake provides a React hook that prevents the screen from sleeping and a pair of functions to enable this behavior imperatively.

Installation

Terminal
- npx expo install expo-keep-awake
- yarn expo install expo-keep-awake
- pnpm expo install expo-keep-awake
- bun expo install expo-keep-awake

If you are installing this in an existing React Native app, make sure to install expo in your project.

Usage

Example: hook

Keep Awake hook
import { useKeepAwake } from 'expo-keep-awake'; import React from 'react'; import { Text, View } from 'react-native'; export default function KeepAwakeExample() { useKeepAwake(); return ( <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Text>This screen will never sleep!</Text> </View> ); }

Example: functions

Keep Awake functions
import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake'; import React from 'react'; import { Button, View } from 'react-native'; export default class KeepAwakeExample extends React.Component { render() { return ( <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Button onPress={this._activate} title="Activate" /> <Button onPress={this._deactivate} title="Deactivate" /> </View> ); } _activate = () => { activateKeepAwake(); alert('Activated!'); }; _deactivate = () => { deactivateKeepAwake(); alert('Deactivated!'); }; }

API

import * as KeepAwake from 'expo-keep-awake';

No API data file found, sorry!