Make the screen not dim (and eventually lock the device) while Insomnia is active.
npm i --save @nativescript-community/insomnia
  • Version: 2.0.2
  • GitHub:
  • Downloads:
    • Last Day:   2
    • Last Week:  13
    • Last Month: 78

NativeScript Insomnia

💡 Plugin version 2.0.0+ is compatible with NativeScript 7+. If you need to target older NativeScript versions, please stick to plugin version 1.2.3.

Demo app (Angular)

This plugin is part of the plugin showcase app I built using Angular.


Run the following command from the root of your project:

tns plugin add @nativescript-community/insomnia


To use this plugin you must first require() it:


var insomnia = require("@nativescript-community/insomnia");


You could do the same as in JS, but this looks fancier, right?

import { keepAwake, allowSleepAgain } from "@nativescript-community/insomnia";


  insomnia.keepAwake().then(function() {
console.log("Insomnia is active");


  insomnia.allowSleepAgain().then(function() {
console.log("Insomnia is inactive, good night!");