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.
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.
packages/wake from the repository; npm package coming soonNoSleep.js 0.12.0: The npm package nosleep.js change event carrying from, to, reason and adviceNoSleep.js 0.12.0: isEnabled, a booleanreacquireOnVisibleNoSleep.js 0.12.0: Yes, on visibilitychange and fullscreenchangelost with a reasonNoSleep.js 0.12.0: Logs a console messageWhen NoSleep.js is the better choice
It is a good library. In these cases we would send you there.
- 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.
- You need a package from npm today
@awaketab/wakeisn'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.
- Your users see the statusA kiosk or dashboard that says "awake" should only say it while the lock holds.
heldmeans a live lock, andfallbackmeans the video is really playing. - 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. - You use a framework
@awaketab/wake/react,/preactand/vueexport auseWakeLock()hook that returns the state withrequestandrelease.
The same job in code
NoSleep.js:
nosleep.jsimport 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.tsimport { 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.
Questions
Soubhik Biswas · Builds AwakeTab. Sources checked Saturday, 26 September 2026. About AwakeTab