Send data to the client without the client having to initiate the request.

Member-only story

Notifications, SSE, SocketIO, & Push API

A comparison and quick tutorial of server to client communication.

Eric Fossas
5 min readNov 27, 2018

--

The Notifications API allows you to use your client’s built in notifications so they don’t have to be viewing your web page to get a notification. It is purely a UI feature.

Server Side Events, Web Sockets, and the Push API, all allow the server to send data to the client (without the client having to initiate a request).

This quick tutorial will show the basic set up and use of these 4 technologies.

Fully functioning examples can be found at: https://github.com/efossas/WebServerAlerts-POC. It’s a proof of concept project for exploring the pros and cons of each technology. In this tutorial, I’ll be using modified versions of that code for teaching. They don’t all work if you just copy and paste.

Also, all of my examples will use NodeJS on the server side.

Keep connected to the client to send live data and notifications.

What This Tutorial Covers

  1. Notification API
  2. Server Side Events
  3. Web Sockets with SocketIO
  4. Push API

What You Need For This Tutorial

Nothing. A browser I suppose and Docker if you want to spin up the POC in the repo mentioned above.

Notification API

The Notification API allows you to use your client’s native notifications. This means that even if they’re not looking at your web page, or even a browser for that matter, they’ll still get a little notification message from you.

IE, Mobile Safari, & Android do not support it.

On a Mac, notifications show up in the upper right hand corner. They can contain a small image and some text. The notification in the POC looks like this:

--

--

No responses yet

Write a response