web-push: a published VAPID private key, require in an ESM package, and tests that fetch browsers
Web Push library for Node.js
At a glance
- What is it?
- web-push-libs/web-push is a six-dependency Node library for the web push protocol whose README prints a complete VAPID key pair including the private key and then reuses it in the CLI example, whose headline usage uses require in a package declared as an ES module, and whose npm test downloads Chromium and Firefox before running anything.
- Who is it for?
- Use it if you need exactly this protocol and are willing to read the source, because the API surface is small, the encryption dependency is pinned, and the option documentation is better than most. Three things to check first.
- Can I use it commercially?
- Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
- Is it still maintained?
- Yes. The repository last received commits 12 days ago.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.
Star history
- web-push-libs/web-push3,577 ★ · +29
| Repository | 2026-09-24 | 2026-11-22 |
|---|---|---|
| web-push-libs/web-push | 3.5k | 3.6k |
29 Stars in the last 59 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
The documentation publishes a VAPID private key and then reuses it in the CLI example
The command-line documentation shows example VAPID public and private keys. Example credentials are public and must not be reused: generate a unique key pair for your application, protect the private key, and use the matching public key when clients subscribe. The examples alone do not establish whether any real subscription endpoint is active or whether the sample values correspond to a deployed application.
The usage example uses require in a package declared as an ES module
The headline example opens like this:
const webpush = require('web-push');
// VAPID keys should be generated only once.
const vapidKeys = webpush.generateVAPIDKeys();
webpush.setGCMAPIKey('<Your GCM API Key Here>');
webpush.setVapidDetails(
'mailto:[email protected]',
vapidKeys.publicKey,
vapidKeys.privateKey
);
// This is the same output of calling JSON.stringify on a PushSubscription
const pushSubscription = {
endpoint: '.....',
keys: {
auth: '.....',
p256dh: '.....'
}
};
webpush.sendNotification(pushSubscription, 'Your Push Payload Text');That is CommonJS. And the manifest declares the package as an ES module, with the type field set to module and the main entry pointing into the source tree.
Those two things are in tension. Under Node's rules before the recent interoperability work, a require of a package whose type is module throws an error saying the module cannot be loaded that way. The manifest's own floor is Node 16, and at every version from 16 up to the version that first allowed requiring an ES module, the first thing a new user copies does not run.
The rest of the README is consistent with itself and with the manifest. The second code example is browser-side and uses no module syntax at all, because it runs in a page. The API reference example also uses require. So the documentation is written throughout for a CommonJS consumer, while the package has been configured for an ES module consumer.
Neither style is wrong on its own. What is wrong is the gap: a reader cannot tell from the README which module system this package wants, and the first line of the first example is the wrong answer.
There is no build step and main points straight at the source file
The scripts section has four entries. One installs browsers for the test run, one lints, one chains the lint and the browser install as a pre-test hook, and one runs the test suite. There is no build script, no compile step and no bundler.
The main field points at a file inside the source directory. The command line binary points at a file inside the source directory too. And there is no files field in the manifest, so what gets published is decided by an ignore file at the repository root rather than by an allow list.
So the distributed package is the source tree, untranspiled, with the entry point and the executable both being files a human wrote. That has a real upside for a library like this one, because there is no build output to drift from the source and a consumer reading the entry point is reading exactly what runs. It also means there is no separate distribution channel for a bundled or minified build, and the CLI ships as a source file rather than as a compiled command.
The one thing to be careful about is the pairing with the module field from the previous section. When there is no build step, whatever module format the source is written in is the format consumers get, and the documented format and the shipped format are not the same one.
Running the tests downloads two browsers first
The test script runs a coverage wrapper around a test runner, against a glob of test files. That part is ordinary.
The pre-test hook is not. It runs two commands in sequence: the lint step, and then a script that invokes a browser automation tool to install both Chromium and Firefox. So the first thing npm does when you ask it to test is download two browsers.
That is a heavy default for a suite that is mostly protocol serialisation and header construction. A library dependency list that includes a browser automation framework, a port finder and a mocking helper tells you what the tests actually do: they start real servers on real ports and drive real browsers against them, which is the right way to test a push client and an expensive way to do it.
The cost lands on whoever runs it. Every test invocation in a fresh environment is a multi-hundred-megabyte download before a single assertion executes. On a continuous integration runner without a browser cache that is minutes and a large network dependency on every job, and on a developer machine it is the kind of pre-step that gets skipped by habit.
The lint coupling is worth noting separately. Because the hook chains lint into pretest, the declared minimum runtime has to satisfy the linter's requirements too, and the manifest's floor is Node 16 while the lint tooling it pins is several major generations newer than that.
Three patch tags published eleven seconds apart, and the manifest is two versions ahead of them
The three releases on record are three patch versions of the same minor line: 3.6.3, 3.6.4 and 3.6.5. All three were published on the same afternoon in August 2023, and the timestamps are eleven seconds apart from first to last.
That is the signature of a tag operation rather than three releases. Nobody ships three patches and their notes in the same eleven seconds; somebody pushed tags in a loop.
Meanwhile the manifest declares version 3.6.7. So the source tree is two patch versions past the newest tag, and there is no release between them. The last commit to the default branch is dated 2026-09-28, six days before this material was fetched, so the code is current and there is still no release.
For a package whose entire job is sending encrypted HTTP requests to push services, that matters in one specific way. Push services change behaviour, and browsers change behaviour, and the version a consumer resolves is the version they can identify when something stops working. A tag stream that stopped three years ago means the only version identifiers that mean anything are the ones in your own lockfile.
There is no changelog in the repository either. The top level has an issue template, a licence, the ignore file, the lint configuration, a lockfile, the manifest and the two source directories. Nothing that records what changed between the versions.
The manifest declares MPL-2.0 and the repository's licence detection reports nothing
The manifest has a licence field, and it names the Mozilla Public License version 2.0. There is a licence file at the top level of the repository, and a file that excludes things from the published package.
And the repository's own licence detection reports no recognised licence at all.
For a package with 3551 stars that is worth chasing down. Detection normally reads the licence file; when it fails, either the file is absent, or it does not begin with text the detector recognises. Since a licence file is present, the most likely explanation is the second, which means the file's contents do not match the string in the manifest.
That produces a specific failure mode for downstream users. Automated compliance tooling, which is how most organisations check a dependency tree, will read a licence string from the manifest and find it is MPL-2.0. A human who clicks through to the licence file will find something else. A scanner that relies on the repository's metadata will find nothing at all.
The package is attributed to a single named author, and the organisation that hosts it is a small group rather than a vendor, so there is no commercial entity to contact about the discrepancy. For anyone whose organisation blocks copyleft licences outright, or requires an explicit licence identifier per dependency, this is the kind of thing that stalls a review for a day.
All three protocol references are draft URLs, one of them attributed to an individual
The Why section sets out the two specifications this library implements, and both links go to a mirror of Internet-Drafts rather than to published standards: the push protocol itself, and the message encryption specification.
The VAPID reference in the options section does the same thing, and this one is more pointed. Its URL carries an author's surname in the draft name rather than a working group name, which is how individual draft documents are identified when no working group has taken ownership of them.
For a library whose entire security surface is the correct construction of an encrypted request body, citing drafts rather than the published standards is a documentation weakness with teeth. A draft is a moving target: its URL is stable, its content is not, and a reader who follows the link gets whatever the current revision says rather than the revision the library was written against.
The library does not pin a revision number anywhere, so there is no way to tell from the documentation which version of which specification the implementation follows.
It is worth saying plainly that the rest of this README is unusually good on semantics. The explanation of the timeout option is a genuinely excellent piece of documentation: it distinguishes a socket timeout from a total response time, explains why a response can take longer than the timeout without timing out, and walks through a worked example with three packets arriving at intervals just under the limit. Very few libraries explain that clearly. The references are the weak part, and they are the part a security review depends on.
The stated common use case is a credential the README itself calls legacy
The usage section opens by naming the scenario it expects: an application server using a GCM API key and VAPID keys. The example then calls the function that sets that credential, then the function that sets the VAPID details, then sends.
The Why section calls the same thing legacy support, for browsers relying on GCM for message sending and delivery. So the document both leads with the legacy path and labels it legacy, without ever saying what replaces it or whether you should still be using it.
The API reference carries the same credential as a documented per-request option, noting that it overrides anything set globally for that request only. So the legacy credential is not a deprecated leftover in one paragraph; it is threaded through the example, the overview and the options list.
That is an unfortunate combination for a new user. The most prominent example in the document is the one the document also warns against, and there is no replacement to migrate to in the visible text.
The rest of the option list is where the documentation earns its keep, by contrast. Time to live is described with a sensible default. Urgency is given as a named set with an explanation of what the highest value does. The topic option explains coalescing and caps the identifier length at 32 characters. And the content encoding option names both the current scheme and the older one, so you know which you are picking when you set it.
Editorial conclusion
Use it if you need exactly this protocol and are willing to read the source, because the API surface is small, the encryption dependency is pinned, and the option documentation is better than most. Three things to check first. Treat the VAPID keys in the README as compromised and generate your own, because they are complete rather than truncated and the same pair is reused in the command example. Decide whether you are a CommonJS or an ES module consumer before you copy anything, since the manifest and the examples disagree. And install the browsers once yourself rather than letting the pre-test hook do it, so you are not downloading two of them on every test run.
Frequently asked questions
How do I install web-push?
With npm install web-push --save for use as a library. There is also a global install, npm install web-push -g, which provides the command line interface with its send-notification and generate-vapid-keys commands.
What does web-push need in order to send a notification?
A push subscription object with an endpoint and a keys object, in the same shape you get from stringifying a PushSubscription in the browser. The payload is optional and may be a string or a Buffer, but encrypting it requires the subscription to carry both the user public encryption key and the auth secret. Authentication is a VAPID key pair generated once.
What are VAPID keys for in web-push?
They identify your application server to the push service. The library generates a pair, the details setter takes a subject, a public key and a private key, and the public key is what you pass as the application server key when the browser subscribes. The subject is a mailto address or a URL.
Is web-push CommonJS or ESM?
The manifest declares the package as an ES module, with main pointing at a file in the source directory and no build step in the scripts. The README's usage and API examples all use require, which does not load an ES module on the Node version the manifest declares as its floor.
What do the TTL and urgency options do in web-push?
TTL is how long the push service retains the message, in seconds, defaulting to four weeks. Urgency tells the service whether to attempt immediate delivery or let the recipient's power considerations win, and takes very-low, low, normal or high. Topic lets the service coalesce notifications under an identifier of up to 32 characters.
What does the web-push timeout option actually measure?
A socket timeout in milliseconds, not a limit on total response time. The README's worked example: with a one second socket timeout and a response of three packets each taking 0.9 seconds to arrive, there is no timeout, because every individual gap is under the limit. The default is undefined.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/web-push-libs-web-push)Star history chart for your README
[](https://hysenlabs.com/projects/web-push-libs-web-push)Was this useful?