PWA Demos
Screen Wake Lock

Screen Wake Lock PWA Demo

The Screen Wake Lock API allows PWAs to request a device to stay awake and prevent the screen or system from entering sleep mode, ensuring continuous operation and display functionality while the app is running.

Screen Wake Lock Logo

Demo

Install the app, open it from your homescreen, then tap the button below to lock the screen.

Limitations

While the Wake Lock functions as expected on iOS Safari 16.4 or higher, it regrettably does not appear functional within PWAs when installed on iPhones or iPads (bug report).

The device may refuse to wake lock the screen for various reasons: low-battery, user preferences, etc. It's generally good practice to handle these cases by wrapping navigator.wakeLock.request() in a try...catch statement.

If the user minimizes a tab, closes a window, or navigates away from the PWA in which a screen wake lock is active, the lock will be released automatically.

Use Cases

The Wake Lock API is useful in certain specific scenarios where uninterrupted screen display and system activity are essential.

For instance, a PWA that streams or records video can utilize the Wake Lock API to prevent screens from dimming or devices from entering sleep mode during playback.

Similarly, real-time collaboration tools can ensure that devices remain awake during active sessions, preventing unexpected disruptions.

The Wake Lock API is a good way to overcome some other limitations of PWAs. For example, audio-recording and geolocation may be interrupted if the devices goes to sleep. By keeping the device awake, you ensure these functions continue working as intended.

Code

Links & Documentation

Your app here

Unlock the powers of the web today

Try our PWA toolkit free of charge and without limits for 14 days. No credit card required.

Get started See plans