Skip to main content
Back to plugins
@capgo/capacitor-keep-awake
Tutorial
@capgo/capacitor-keep-awake

Keep Awake

Prevent device screen from dimming or sleeping for video players, navigation, and presentations

Guide

Tutorial on Keep Awake

Test on device

Download the Capgo app, then scan the QR code.

Keep Awake plugin preview QR code

Using @capgo/capacitor-keep-awake

Capacitor Keep Awake Plugin for preventing the device screen from dimming/sleeping.

Install

bun add @capgo/capacitor-keep-awake
bunx cap sync

What This Plugin Exposes

  • keepAwake - Prevent the device from dimming the screen.
  • allowSleep - Allow the device to dim the screen (disable keep awake).
  • isSupported - Check if the keep awake feature is supported on the current platform.
  • isKeptAwake - Check if the device is currently being kept awake.

Example Usage

keepAwake

Prevent the device from dimming the screen.

import { KeepAwake } from '@capgo/capacitor-keep-awake';

await KeepAwake.keepAwake();
console.log('Screen will stay awake');

allowSleep

Allow the device to dim the screen (disable keep awake).

import { KeepAwake } from '@capgo/capacitor-keep-awake';

await KeepAwake.allowSleep();
console.log('Screen can now dim');

isSupported

Check if the keep awake feature is supported on the current platform.

import { KeepAwake } from '@capgo/capacitor-keep-awake';

const { isSupported } = await KeepAwake.isSupported();
if (isSupported) {
  console.log('Keep awake is supported');
}

isKeptAwake

Check if the device is currently being kept awake.

import { KeepAwake } from '@capgo/capacitor-keep-awake';

const { isKeptAwake } = await KeepAwake.isKeptAwake();
console.log('Is kept awake:', isKeptAwake);

Full Reference

Keep going from Using @capgo/capacitor-keep-awake

If you are using Using @capgo/capacitor-keep-awake to plan native media and interface behavior, connect it with @capgo/capacitor-keep-awake for the implementation detail in @capgo/capacitor-keep-awake, Getting Started for the implementation detail in Getting Started, Using @capgo/capacitor-live-activities for the native capability in Using @capgo/capacitor-live-activities, @capgo/capacitor-live-activities for the implementation detail in @capgo/capacitor-live-activities, and Using @capgo/capacitor-video-player for the native capability in Using @capgo/capacitor-video-player.