Listen for `install` and `activate` PWA Events in a Service Worker

Share this video with your friends

Send Tweet

Service workers are event-based, so we'll listen for the install and activate events, which will let us execute code when our PWA gets installed for the first time. We'll use setTimeout to simulate an asynchronous action and wait for that to complete, before allowing the PWA to continue installing.