Scheduling Tasks with the Alarms API
Run periodic and delayed background work reliably in a Manifest V3 service worker using chrome.alarms.
Why Not setInterval
In Manifest V3 the service worker unloads when idle, so setTimeout and setInterval are unreliable for scheduled work. The alarms API survives this by waking the worker when it is time to run.
Declaring the Permission
Add the alarms permission to the manifest before using the API.
{
"permissions": ["alarms"]
}All lessons in this course
- Tab Management and Control
- Programmatic Form Submission
- Automating User Interactions
- Scheduling Tasks with the Alarms API