Skip to content
Compare

NoSleep.js vs @awaketab/wake

NoSleep.js 0.12.0, its last release (16 December 2020), already calls the Screen Wake Lock API when the browser has it, and falls back to a hidden looping video when it doesn't. If it works for you, there is no emergency. @awaketab/wake takes the same first step, then tells your code what happened: seven states, and a reason with every change. It is an actively maintained alternative, MIT-licensed.

Sources checked Saturday, 26 September 20263 min readBy Soubhik Biswas

Side by side

When NoSleep.js was written, a silent video was the only way to keep most phones awake. The Screen Wake Lock API arrived in Chrome and Edge 84 (July 2020), Safari 16.4 (March 2023) and Firefox 126 (May 2024). For the API itself, see Screen Wake Lock API: a practical guide with error handling. Facts about NoSleep.js come from its source on GitHub. Rows marked Same are real ties.

How it keeps the screen on@awaketab/wake: Wake Lock API; a video fallback after a tap, only where the API is missingNoSleep.js 0.12.0: Wake Lock API if present; hidden looping video otherwise; a page-reload timer on very old iOS
With the tab hiddenSame@awaketab/wake: NoNoSleep.js 0.12.0: No
Install@awaketab/wake: Copy packages/wake from the repository; npm package coming soonNoSleep.js 0.12.0: The npm package nosleep.js
Platforms@awaketab/wake: Browsers; returns an inert handle during server renderingNoSleep.js 0.12.0: Browsers
Status@awaketab/wake: Seven states, with a change event carrying from, to, reason and adviceNoSleep.js 0.12.0: isEnabled, a boolean
Asks again after the tab returns@awaketab/wake: Yes, on both, controlled by reacquireOnVisibleNoSleep.js 0.12.0: Yes, on visibilitychange and fullscreenchange
When the browser takes the lock back@awaketab/wake: Moves to lost with a reasonNoSleep.js 0.12.0: Logs a console message
Licence and priceSame@awaketab/wake: MIT, freeNoSleep.js 0.12.0: MIT, free
Last release@awaketab/wake: Source on GitHub; not yet publishedNoSleep.js 0.12.0: 0.12.0, 16 December 2020

When NoSleep.js is the better choice

It is a good library. In these cases we would send you there.

  1. It already works and you only show an on/off switchOn current browsers it makes the same API call. Switching buys you status reporting, not a stronger lock.
  2. You need a package from npm today@awaketab/wake isn't published yet, and some teams can't vendor source.

When @awaketab/wake is the better choice

These are the jobs @awaketab/wake was built for.

  1. Your users see the statusA kiosk or dashboard that says "awake" should only say it while the lock holds. held means a live lock, and fallback means the video is really playing.
  2. You need to know why it failedA missing allow="screen-wake-lock" on an iframe, a hidden page and an http origin each get their own advice code.
  3. You use a framework@awaketab/wake/react, /preact and /vue export a useWakeLock() hook that returns the state with request and release.

The same job in code

NoSleep.js:

nosleep.js
import NoSleep from 'nosleep.js'; const noSleep = new NoSleep();startButton.addEventListener('click', () => {  noSleep.enable().catch((err) => console.warn(err.name));});stopButton.addEventListener('click', () => noSleep.disable());

@awaketab/wake:

wake.ts
import { createWakeLock } from '@awaketab/wake'; const lock = createWakeLock();lock.on('change', ({ from, to, reason, advice }) => {  console.log(`${from} -> ${to} (${reason})`, advice ?? '');});startButton.addEventListener('click', () => lock.request());stopButton.addEventListener('click', () => lock.release());

request() does not throw. It resolves with the resulting state: held when the browser grants the lock, fallback when the video is playing, denied or unsupported when neither worked. When a state changes for a reason you can act on, advice names it, for example hidden_document, permissions_policy, iframe_no_allow or insecure_context.

The @awaketab/wake library page has a live demo of every state.

Try it hereTry itStart a session, switch tabs, then come back and watch the pill. Ends at … if you start now.Start a 15-minute session

Questions

On browsers with the Screen Wake Lock API, yes: version 0.12.0 calls navigator.wakeLock.request('screen') first. Its video path is only reached where the API is missing. We have not re-checked that video path on current iOS.

Soubhik Biswas · Builds AwakeTab. Sources checked Saturday, 26 September 2026. About AwakeTab