web-push

Node.js library for sending Web Push notifications with VAPID and payload encryption

Library
npm
v3.6.7
3,549 stars
Mozilla Public License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
79 /100 Good
Development Activity 84
Maintenance 64
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
75 /100 Good
Architecture 76
Code Quality 78
Innovation 74
Learning Curve 72

web-push is a Node.js library that implements the Web Push Protocol and its accompanying Message Encryption spec, letting an application server send push messages to a subscribed browser without running its own push infrastructure. It handles VAPID key generation and signing, per-message payload encryption (aes128gcm and the legacy aesgcm scheme), and the raw HTTPS request to whichever push service (FCM, Mozilla, or another vendor endpoint) owns the subscription.

Beyond the JS API, the package ships a web-push CLI for generating VAPID key pairs and firing test notifications from the command line, which makes it a common first stop for teams wiring up browser push notifications on top of the standard Push API and Notifications API.

What You Get

  • sendNotification(subscription, payload, options) — encrypts an optional payload and POSTs it to the subscription’s push service endpoint, returning a Promise
  • generateVAPIDKeys() / setVapidDetails() — VAPID key pair generation and application-server identification for authenticating push requests
  • Built-in payload encryption implementing the Message Encryption for Web Push spec (aes128gcm, with legacy aesgcm support)
  • A web-push CLI binary for generating VAPID keys and sending test notifications without writing code
  • Support for proxy, custom HTTPS agent, TTL, urgency, topic (notification coalescing), and per-request timeout options
  • Legacy GCM API key support (setGCMAPIKey) for older Android push endpoints

Common Use Cases

  • Sending browser push notifications from a Node.js backend to subscribers registered via the Push API
  • Re-engagement and transactional alerts for PWAs (new message, order update, price drop) without a third-party notification SaaS
  • Generating and rotating VAPID key pairs for a self-hosted push notification service
  • Building a lightweight notification worker/queue consumer that calls sendNotification() per subscriber

Under The Hood

Architecture — The package is a thin, single-purpose pipeline: src/index.js exposes a small functional surface backed by one WebPushLib class instance (src/web-push-lib.js) that holds module-level gcmAPIKey/vapidDetails state. sendNotification() first calls generateRequestDetails(), which validates the subscription, merges per-call options over the stored defaults, optionally runs the payload through encryption-helper.js, and picks an auth strategy (VAPID header via vapid-helper.js, or a legacy GCM/FCM API key) based on the subscription endpoint’s hostname. The resulting { endpoint, headers, body } is then handed to a node:https request wrapped in a Promise, with an optional https-proxy-agent swapped in when a proxy option is set. src/cli.js is a separate thin wrapper that parses minimist argv and calls into the same library. Tech Stack — Plain ESM JavaScript ("type": "module") for Node >= 16, with no TypeScript and no framework dependency. Runtime dependencies are minimal and purpose-built: asn1.js (DER-encodes EC private keys for VAPID JWT signing), jws (JWT signing), http_ece (Encrypted Content-Encoding for payload encryption), https-proxy-agent, and minimist for CLI parsing. Dev tooling is mocha + c8 for tests/coverage, eslint (flat config) for linting, and Playwright for browser-based encryption interop tests. Code Quality — The test/ directory has 8 test files with unit coverage over VAPID header generation, encryption, CLI argument handling, and setGCMAPIKey/setVapidDetails, plus a testBrowsers.js that exercises real payload decryption in Playwright-driven browsers to validate protocol interop rather than just unit-testing the crypto locally. Input validation is thorough and defensive — generateRequestDetails() rejects unknown option keys, malformed subscriptions, and invalid TTL/urgency/topic/proxy/agent values with descriptive errors before any network call is attempted. The code favors plain functions and explicit checks over abstraction layers, keeping the failure surface easy to trace. API Design — The public API is deliberately small: one function to send a notification, one to generate VAPID keys, one to set them globally, and generateRequestDetails() exposed separately for callers who want the raw request shape without an HTTP call (e.g. to send it through their own client). Global mutable state for VAPID/GCM defaults (set once via setVapidDetails) trades some purity for a shorter call site in the common case, with per-call options.vapidDetails available as an escape hatch. Errors carry the push service’s status code, headers, and body via a dedicated WebPushError class, making upstream failures (expired subscriptions, invalid VAPID audience, etc.) programmatically distinguishable from network errors.

Used by 11 apps in this directory

JavaScript
95%
MIT

AnythingLLM

AI Assistants · Automation · Developer Tools

66,533

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
90
Repo Health
78
Technical
64
Dependency
Built with
JavaScript 95%
Updated 6 days ago
TypeScript
96%
Other

Cal.diy

Scheduling

48,697

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
91
Repo Health
86
Technical
65
Dependency
Built with
TypeScript 96%
Updated 6 days ago
TypeScript
61%
EPL-2.0

Huly Platform

Collaboration · Project Management · Team Chat

27,797

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
62
Dependency
Built with
TypeScript 61%
Svelte 34%
Updated 6 days ago
TypeScript
95%
Apache 2.0

OneUptime

Monitoring

7,668

The complete open-source observability platform that replaces PagerDuty, Datadog, Sentry, and StatusPage with a single self-hostable system.

View details
91
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 95%
Updated 4 days ago
TypeScript
91%
MIT

OpenClaw

AI Agents · AI Assistants

390,670

An open-source AI assistant that runs on your own hardware and meets you in Discord, Slack, WhatsApp, iMessage, Telegram, and 20+ other channels, with native apps for every major platform.

View details
88
Repo Health
88
Technical
68
Dependency
Built with
TypeScript 91%
Updated 4 days ago
Vue
41%
AGPL 3.0

Operational

Analytics · Automation · Monitoring

475

Open-source event tracker with real-time push notifications and action buttons for tech founders.

View details
52
Repo Health
68
Technical
68
Dependency
Built with
Vue 41%
JavaScript 38%
MDX 13%
Updated 2 months ago
TypeScript
55%
MIT

optio

AI Agents · AI Code Assistants

1,054

Self-hosted AI agent workflow orchestration that runs on your Kubernetes cluster — from ticket intake to squash-merged PR, entirely within your infrastructure.

View details
80
Repo Health
81
Technical
70
Dependency
Built with
TypeScript 55%
Kotlin 32%
Swift 12%
Updated 6 days ago
TypeScript
98%
MIT

SplitPro

Invoicing Finance

1,458

Self-hosted, open source expense splitting with multi-currency, recurring bills, and bank imports — a complete Splitwise replacement you control.

View details
77
Repo Health
77
Technical
69
Dependency
Built with
TypeScript 98%
Updated 1 months ago
TypeScript
97%
AGPL 3.0

Swetrix

Analytics

1,200

Privacy-first, cookieless web analytics with error tracking, session replays, and performance monitoring — self-host or use Cloud.

View details
88
Repo Health
71
Technical
66
Dependency
Built with
TypeScript 97%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers