Comparison
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.
On this page
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 soon The npm package nosleep.js change event carrying from, to, reason and advice isEnabled, a boolean reacquireOnVisible Yes, on visibilitychange and fullscreenchange lost with a reason Logs a console message When 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 switch On 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 status A 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 failed A 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:
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:
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
Start a session, switch tabs, then come back and watch the pill.
Questions
Does NoSleep.js still work in 2026?
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.
Is @awaketab/wake a drop-in replacement for NoSleep.js?
No. The calls differ: createWakeLock(), request() and release() instead of new NoSleep(), enable() and disable(). Moving over is a few lines, and in return you get change events you can show to your users.
Why does the video fallback need a click?
Browsers block video autoplay until the person has interacted with the page. If play() is refused, @awaketab/wake stays in the unsupported state and emits an error event, so call request() again from a click or tap handler.
Can I use @awaketab/wake before the npm package is out?
Yes. The source is MIT-licensed in the packages/wake folder of the AwakeTab repository on GitHub. Copy it into your project and build it with your own bundler. The npm package is coming soon.