Free Web Push Notification Updates: Just Subscribe to receive notifications.
- Node.js
- Express.js for API
- HTML, Bulma CSS and Javascript for Front-end
- Browser IndexedDB Support for Store Push Notifications
- PWA install Support
- Web Push Notifications with VAPID: https://rossta.net/blog/using-the-web-push-api-with-vapid.html
- API Routes for
/api/subscribe
,/api/unsubscribe
,/api/resubscribe
,/api/send-notification
- All Client Subscribed data was stored in
db
folder in jSON File Format - Automatically removed and Update inactive client tokens in JSON File
- Bearer Token Support for Send Notification API Route
- Clone or Download the Repo
- install dependencies (pnpm recommended)
# dev server
pnpm dev
# Production server
pnpm start
- Fully Self-Hosted no third party sdk or api not required
- Generate web push vapid key
npx web-push generate-vapid-keys [--json]
- Create
db
folder for store client tokens
mkdir -p db
index.js
- add vapid key details and Email-IDsrc/middleware/auth.js
add custom key for Bearer Auth Headerpublic/sw.js
Update your Website URLpublic/main.js
Update your PUblic Vapid Key- Send Push NOtification to all clients
curl -X POST http://localhost:5024/api/send-notification -H "Authorization: Bearer YOURKEY" -H "Content-Type: application/json" -d '{"title": "First Push", "body": "Hello World"}'
- Send to only one device: K0IN/Notify#122
- Project idea from : https://github.com/K0IN/Notify
- Concept Web Push from service worker : https://github.com/gauntface/simple-push-demo
- VAPID : https://developer.chrome.com/blog/web-push-interop-wins
- Project base concept : https://dev.to/wteja/how-to-make-push-notification-using-nodejs-and-service-worker-jaa
MIT