Wake Lock
Browser Support
Usage
Basic Wake Lock Toggle
<div {{ stimulus_controller('@pwa/wake-lock') }}>
<button {{ stimulus_action('@pwa/wake-lock', 'toggle', 'click') }}>
Toggle Screen Wake Lock
</button>
<p id="status">Wake lock status: <span>Not active</span></p>
</div>
<script>
document.addEventListener('pwa--wake-lock:updated', (event) => {
const status = event.detail.wakeLock;
const statusText = status && !status.released ? 'Active' : 'Not active';
document.querySelector('#status span').textContent = statusText;
});
</script>Explicit Lock and Unlock
Recipe App Example
Parameters
Actions
lock
lockunlock
unlocktoggle
toggleTargets
Events
pwa--wake-lock:updated
pwa--wake-lock:updatedBest Practices
Common Pitfalls
Complete Example
Last updated
Was this helpful?