web-push

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

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
77/100Good
Development Activity80
Maintenance60
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture76
Code Quality78
Innovation74
Learning Curve72

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 10 apps in this directory

JavaScript
95%
MIT

AnythingLLM

Developer Tools · Automation · AI Assistants

64,914

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

View details
91
Repo Health
78
Technical
68
Dependency
Built with
JavaScript95%
Updated today
TypeScript
96%
Other

Cal.diy

Scheduling

47,796

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

View details
93
Repo Health
86
Technical
66
Dependency
Built with
TypeScript96%
Updated 1 weeks ago
TypeScript
61%
EPL-2.0

Huly Platform

Project Management · Team Chat · Collaboration

27,384

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
64
Dependency
Built with
TypeScript61%
Svelte34%
Updated 1 weeks ago
TypeScript
92%
Apache 2.0

OneUptime

Monitoring

7,481

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

View details
90
Repo Health
81
Technical
66
Dependency
Built with
TypeScript92%
Updated today
Vue
41%
AGPL 3.0

Operational

Analytics · Automation · Monitoring

476

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

View details
57
Repo Health
68
Technical
72
Dependency
Built with
Vue41%
JavaScript38%
MDX13%
Updated 3 weeks ago
TypeScript
99%
MIT

optio

AI Agents · AI Code Assistants

1,034

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
77
Repo Health
81
Technical
70
Dependency
Built with
TypeScript99%
Updated 1 weeks ago
TypeScript
98%
MIT

SplitPro

Invoicing Finance

1,400

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

View details
86
Repo Health
77
Technical
70
Dependency
Built with
TypeScript98%
Updated 3 days ago
TypeScript
97%
AGPL 3.0

Swetrix

Analytics

1,123

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

View details
87
Repo Health
71
Technical
71
Dependency
Built with
TypeScript97%
Updated yesterday
JavaScript
56%
MIT

Uptime Kuma

Monitoring

90,349

Self-hosted monitoring for every service you run — 23 monitor types, 95 notification channels, live dashboards, and public status pages with no vendor lock-in.

View details
91
Repo Health
81
Technical
67
Dependency
Built with
JavaScript56%
Vue42%
Updated today

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

Search