Skip to main content

cordova-plugin-insomnia Alternative for Capacitor

cordova-plugin-insomnia alternative for Capacitor: prevent screen sleep during navigation or kiosks with @capgo/capacitor-keep-awake.

Illustration of migrating a Cordova app to Capacitor, used for a keep awake plugin guide

The practical cordova-plugin-insomnia alternative for a Capacitor app is @capgo/capacitor-keep-awake. It maps window.plugins.insomnia keepAwake and allowSleepAgain callbacks to KeepAwake promises, adds isKeptAwake and isSupported, and drops the Cordova exec bridge. This guide lists npm facts, install steps, usage, and an API map for your Cordova to Capacitor move.

Why leave cordova-plugin-insomnia in Capacitor

cordova-plugin-insomnia on npm is version 4.3.0. The registry modified timestamp is 14 June 2022. The npm repository URL points to EddyVerbruggen/Insomnia-PhoneGap-Plugin.

The README and www/Insomnia.js document window.plugins.insomnia with:

  • keepAwake(successCallback, errorCallback)
  • allowSleepAgain(successCallback, errorCallback)

In a Capacitor codebase the Cordova plugin still waits for deviceready and uses success or error callbacks with no typed status helpers.

@capgo/capacitor-keep-awake latest on npm is 8.1.22 with a modified date of 12 November 2026. src/definitions.ts documents keepAwake(), allowSleep(), isKeptAwake(), and isSupported(). Capgo ships fixes on an open source cadence where a human still reviews, tests and merges 50+ pull requests daily.

Install

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

No manifest entries are required beyond what Capacitor already declares for wake lock on each platform.

Usage example

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

export async function startGuidedWalkthrough() {
  const { isSupported } = await KeepAwake.isSupported();
  if (!isSupported) return;

  await KeepAwake.keepAwake();
  const { isKeptAwake } = await KeepAwake.isKeptAwake();
  console.log('screen held awake', isKeptAwake);
}

export async function endGuidedWalkthrough() {
  await KeepAwake.allowSleep();
}

Migrating from Cordova to Capacitor

// Before (Cordova)
window.plugins.insomnia.keepAwake(
  function () {
    console.log('awake');
  },
  function (err) {
    console.error(err);
  },
);
// After (Capacitor)
import { KeepAwake } from '@capgo/capacitor-keep-awake';

await KeepAwake.keepAwake();
console.log('awake');
// Before (Cordova)
window.plugins.insomnia.allowSleepAgain(success, error);
// After (Capacitor)
await KeepAwake.allowSleep();

API mapping table

cordova-plugin-insomnia (window.plugins.insomnia) @capgo/capacitor-keep-awake
keepAwake(success, error) keepAwake()
allowSleepAgain(success, error) allowSleep()
Not in Cordova www isKeptAwake() returns { isKeptAwake }
Not in Cordova www isSupported() returns { isSupported }
cordova.plugins.brightness.setKeepScreenOn Also maps here; see brightness plugin docs
Cordova plugin install bun add @capgo/capacitor-keep-awake plus bunx cap sync

Wake lock calls ship in the native binary. Use Capgo Build for store builds. After release, regression test kiosk and navigation flows that toggle awake state, including backgrounding, using the checklist for validating Capacitor app updates. UI-only timing changes can ship with Capgo live updates. For the full platform move, read the Cordova to Capacitor migration guide.

Live updates for Capacitor apps

When a web-layer bug is live, ship the fix through Capgo instead of waiting days for app store approval. Users get the update in the background while native changes stay in the normal review path.

Latest from our Blog

Capgo gives you the best insights you need to create a truly professional mobile app.