node-argon2 ships prebuilt N-API binaries for six platforms, and plans to shrink into a wrapper over node:crypto
Node.js bindings for Argon2 hashing algorithm
At a glance
- What is it?
- node-argon2 binds the reference Argon2 C implementation to Node.js, with hash and verify as the main calls. This article covers the defaults it sets, the prebuilt binary matrix, the source-build escape hatches, and its stated plan to become a thin layer over Node's native Argon2.
- Who is it for?
- Use node-argon2 if you hash passwords in Node 22 or newer and want argon2id with the Argon2 team's recommended defaults, PHC string output and a re-hash check without reading the spec. Skip it, or plan the migration, if you only need raw Argon2 output, because node:crypto now provides generation natively.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 2 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 26, 2026, and from our analysis. They are not legal advice.
Star history
- ranisalt/node-argon22,194 ★ · +6
| Repository | 2026-10-08 | 2026-11-26 |
|---|---|---|
| ranisalt/node-argon2 | 2.2k | 2.2k |
6 Stars in the last 49 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Two calls cover the whole password flow, and argon2id is the default
node-argon2 provides bindings to the reference Argon2 implementation from the P-H-C project. It can hash with Argon2i, Argon2d or Argon2id, and Argon2id is the default. The usage is two awaited calls:
const argon2 = require("argon2");
try {
const hash = await argon2.hash("password");
} catch (err) {
//...
}Verification passes the stored hash first and the candidate password second:
try {
if (await argon2.verify("<big long hash>", "password")) {
// password match
} else {
// password did not match
}
} catch (err) {
// internal failure
}The two outcomes differ. A wrong password makes verify resolve to false. A throw means something internal failed, such as a malformed hash string, so the catch branch should not be treated as a rejected login. A callout in the project says the default parameters follow the recommendations of the team that develops Argon2, and that for password hashing there is no need to change them.
Output length, encoding and cost parameters live on a wiki page, not in the README
Hash length, output encoding, time cost, memory cost and parallelism can all be changed, but the option list is not in the repository's main documentation. It points to the project wiki page named Options. That page is where you find names and accepted values, and the README itself gives no example of passing an options object.
A second wiki article covers migrating from another hash function to Argon2, which is the path for an application that currently stores bcrypt or similar hashes. The README calls that migration easy and gives no steps in the document itself. Check the wiki before planning a rolling upgrade, because the main page does not explain how old and new hashes coexist in one table.
The practical rule from the README is to leave the parameters alone for password storage. Tuning memory and time cost is a decision about your server's capacity, and the package gives you the knobs without telling you the values. The defaults are the author's answer to that, and the discussion linked from the comparison table, issue 469, is where the reasoning for sensible defaults is recorded.
Node's native Argon2 lacks PHC strings, verification and re-hash checks
node:crypto now includes an Argon2 function, and the README compares the two in a table. Both generate hashes. Only node-argon2 formats PHC strings, verifies a PHC string, checks whether a re-hash is needed, and provides sensible default parameters. The native column shows a cross for all four.
The README explains the split in purpose: the native API targets generic use of the Argon2 function, while this package has historically focused on password hashing. If you need to encode salt, parameters and hash into one storable string, or decide on login whether an old hash should be upgraded, you either write that code or use this package.
The project also states its future. Once every supported Node release includes native Argon2 and older versions are officially end of life, node-argon2 will turn into a minimal wrapper. It will offer the developer-friendly interface and pass through to Node's native crypto methods, to avoid duplication and keep upgrades smooth. No date is given. For a new project the practical reading is that the import name and the hash and verify calls are what the author intends to preserve.
Prebuilt binaries cover six systems, with ARM support added in stages
Prebuilt binaries have shipped since v0.26.0 and are built on every release with GitHub Actions. The current set is built and tested on Ubuntu 22.04 (x86-64, with ARM64 from v0.28.2 and ARMv7 from v0.43.0), MacOS 13 (x86-64), MacOS 14 (ARM64 from v0.29.0), Windows Server 2022 (x86-64), Alpine Linux 3.18 (x86-64 from v0.28.1, ARM64 from v0.28.2, ARMv7 from v0.43.0) and FreeBSD 14 (x86-64 from v0.29.1, ARM64 from v0.44.0).
Two notes qualify the list. Binaries should work on newer releases of those systems: the Ubuntu 20.04 binary runs on 22.04 or any Linux with a newer glibc, and the MacOS 11 binary runs on 12. And Windows appears only as x86-64, so a Windows on ARM machine is not in the table.
The package.json files list shows what ships in the npm tarball: argon2.cpp, binding.gyp, selected C sources from the vendored argon2 directory, and prebuilds under prebuilds/ with a .node extension. The install script runs cross-env ZERO_AR_DATE=1 node-gyp-build, which picks a matching prebuild at install time. The build script uses prebuildify with the napi flag and N-API version 8, so one binary serves several Node releases.
Building from source needs node-gyp installed globally and a modern compiler
The source build is the fallback for platforms outside the matrix, and the README says you can skip its instructions when the prebuilt binary works. It then marks one requirement in capital letters: a global node-gyp install, with GCC 5 or newer or Clang 3.3 or newer. On Windows you need Visual Studio 2015 or newer. The package works with, and is tested against, Node 22.0.0 and above, which rules out older runtimes.
The OSX walk-through shows the order. Install GCC with Homebrew, install node-gyp globally, then install the library while naming the compiler:
$ brew install gcc$ npm install -g node-gyp$ CXX=g++-12 npm install argon2If your compiler binary is not called g++-12, put its real name in the CXX variable. A version mismatch there is the likeliest reason the compile step fails on a Mac. The README also notes that it is always recommended to build from source to ensure consistency of the compiled module, which is a stricter policy than the prebuilt default and costs you a toolchain on every deployment host.
Two flags force a compile, and rebuilding needs node-pre-gyp rather than node-gyp
The FAQ gives two ways to skip the prebuilt download. The first forces a compile during install:
$ npm install argon2 --build-from-sourceThe second ignores the install script and builds by hand:
$ npm install argon2 --ignore-scripts
$ npx node-gyp rebuild -C ./node_modules/argon2To rebuild an existing install, run the mapbox tool, not plain node-gyp:
$ npx @mapbox/node-pre-gyp rebuild -C ./node_modules/argon2The reason given is that binding.gyp relies on variables from @mapbox/node-pre-gyp. You can drop the npx @mapbox prefix and run node-pre-gyp directly if it is installed globally, otherwise npx uses the local copy in ./node_modules/.bin.
The two documented methods are not interchangeable. The ignore-scripts path uses node-gyp, while the rebuild answer says node-pre-gyp is required for binding.gyp. If one fails on your machine, the README does not say which to prefer, so try the install flag first, since it keeps the project's own install script in the loop.
A snap-packaged Node cannot install it, and the suggested fix is another Node manager
One failure is named outright. If Node was installed as a snap, installing node-argon2 does not work. The FAQ attributes it to snap itself and links issue 345, and suggests installing Node through a different manager such as asdf or nvm as a workaround. The wording is that this seems to be a snap-related issue, so the cause is not fully pinned down, and the workaround is described as possible, not guaranteed.
The TypeScript story has no such trouble. A declaration file ships with the module, so TypeScript 2.0.0 or later needs no separate typings. The sample imports it as import * as argon2 from "argon2" and calls argon2.hash. The package type is commonjs with argon2.cjs as main and argon2.d.cts as types, so an ES module project should check how its bundler or runtime handles a CommonJS entry.
On project status, the latest releases are v0.45.1 on 21 July 2026 and v0.45.0 on 18 July 2026, after v0.44.0 on 10 August 2025. The repository was last pushed to on 17 October 2026, and it is not archived. It is MIT licensed, and the package version in package.json matches the newest release.
Editorial conclusion
Use node-argon2 if you hash passwords in Node 22 or newer and want argon2id with the Argon2 team's recommended defaults, PHC string output and a re-hash check without reading the spec. Skip it, or plan the migration, if you only need raw Argon2 output, because node:crypto now provides generation natively. Verify first that your platform appears in the prebuilt list, or that you can run node-gyp with GCC 5 or Clang 3.3, since a missing binary turns npm install into a compile.
Frequently asked questions
Is Argon2 still secure?
The repository does not assess Argon2 itself. It states that argon2.hash generates hashes according to the security recommendations of the team that develops Argon2, so for password hashing the defaults need no changes.
Is Argon2 better than SHA256?
The repository makes no comparison with SHA256. It describes node-argon2 as bindings to the reference Argon2 implementation, used to hash and verify passwords with Argon2i, Argon2d or Argon2id.
What is the Argon2 algorithm used for?
Here it is used for password hashing: argon2.hash creates a hash and argon2.verify checks a password against it. The default variant is Argon2id.
Which is better, bcrypt or Argon2?
The repository does not compare Argon2 with bcrypt. Its only comparison is between node-argon2 and node:crypto's native Argon2, and its wiki has a guide for migrating from another hash function to Argon2.
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/ranisalt-node-argon2)Star history chart for your README
[](https://hysenlabs.com/projects/ranisalt-node-argon2)Was this useful?