
Retrieve saved subscriptions and trigger a push message.Send a subscription to our backend and save it.Note: If you want a library for a different language, checkout the web-push-libs organization on Github.

We are looking at Node since it's JavaScript and should be the most accessible for readers. Other languages will have differences, but they won't be too dissimilar. In this section we'll be using the web-push Node library. For now, we are going to look at managing subscriptions and using an existing web push library to make the push requests. If you really want to learn about what the libraries are doing, we'll cover it in the next section. For this reason, I strongly recommend using a library to handle the encryption, formatting and triggering of your push message. This is improving with time and wider browser support but it's far from easy. The main issue with triggering push is that if you hit a problem, it's difficult to diagnose the issue. To send data with a push message, the data needs to be encrypted and specific headers need to be added so the browser can decrypt the message correctly.

application server keys) which basically requires setting a header with a value proving your application can message a user. To use push across all browsers you need to use VAPID (a.k.a. To trigger a push message an application needs to make a POST request to a push service following the web push protocol. One of the pain points when working with web push is that triggering a push message is extremely "fiddly".
