How betaflag/react-push-notification-demo works
This repository is a React client and Node/Express server demo for browser push notifications. The user opens the client, which registers a push service worker, fetches the server’s VAPID public key, subscribes through the browser Push API, and posts the subscription to the server. Clicking “Trigger Notification” calls the server, which looks up that browser’s in-memory subscription and sends a push. The push worker displays the notification. The client also includes an optional, separately registered app service worker for caching/offline behavior. Edges reflect the shown source and README; the external push-delivery hop is implied, not shown.
Main entry points: server.js Express API · pushServiceWorker.js Push Registration · index.js Client Entry · App.js React App
Components 11
React Client
- React App
client/src/App.js - Client Entry
client/src/index.js - App Service Worker
client/src/serviceWorker.js
Push Registration
- Push Registration
client/src/pushServiceWorker.js - Push Service Worker
client/public/push-service-worker.js
Push Server
- Express API
server/server.js - Memory Subscriptions
server/server.js - VAPID Configuration
server/server.js
Other components
- User
- Browser APIs
- Push Service
Connections 16
- User → React App: uses
- Client Entry → React App: renders
client/src/index.js - Client Entry → App Service Worker: unregisters
client/src/index.js - Client Entry → Push Registration: registers
client/src/index.js - Push Registration → Browser APIs: registers worker
client/src/pushServiceWorker.js - Push Registration → Express API: fetches VAPID key
client/src/pushServiceWorker.js - Express API → VAPID Configuration: serves public key
server/server.js - Push Registration → Browser APIs: subscribes
client/src/pushServiceWorker.js - Push Registration → Express API: posts subscription
client/src/pushServiceWorker.js - Express API → Memory Subscriptions: stores subscription
server/server.js - React App → Express API: requests notification
client/src/App.js - Express API → Memory Subscriptions: reads subscription
server/server.js - Express API → Push Service: sends push
server/server.js - Push Service → Push Service Worker: delivers push
- Push Service Worker → Browser APIs: shows notification
client/public/push-service-worker.js - App Service Worker → Browser APIs: uses service worker APIs
client/src/serviceWorker.js