Web Push API Example including Service Worker and minimalistic Application Server

Open the dev tools to get more insights in the console.

This demo is using the web-push lib on server side and VAPID.

Step 1: Get Notification API Permission

First, we need the users permission for showing notifications.

Step 2: Subscribe

To generate a subscription, a public key must be provided. This public key is fetched from our server, where a key pair is stored. With the corresponding private key, the push message will be later encrypted.