This is an example project presenting how to send Push Notifications to the browser. The notification is send using VAPID authentication method.
https://notifications-demo.ertrzyiks.me
Client side components:
-
Manages subscription
-
Receives push notification in background
-
Displays system notifications
Server side components:
- web-push to send notifications
For the most recent information refer to: https://caniuse.com/#feat=push-api,notifications,serviceworkers
- Install npm dependencies
yarn install
- Copy .env.sample file as .env
- Generate VAPID keys
yarn web-push generate-vapid-keys
- Save the provided keys in the
.env
file as
VAPID_PRIVATE_KEY=BEkyy4.....ef7graNA
VAPID_PUBLIC_KEY=B5A.....dRE
- Update value of
VAPID_EMAIL
in the.env
file - Start the server
yarn start