qr.js is a minimalist JavaScript library designed for encoding QR codes directly within the browser or Node.js environments. Published as version 0.0.0, the package has been unmaintained since its last update in November 2015. It is notable for its pure JavaScript implementation with no external dependencies, repackaging work from a Japanese qrcode library. Despite its initial purpose and wide adoption in older projects, its lack of maintenance and critical security issues, including a repository hijacking incident, make it unsuitable for new development. Developers are strongly advised to consider modern, actively maintained alternatives for QR code generation to ensure security and compatibility.
npm install qr.jsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `qr.js` to encode a string into a QR code data structure and inspect its underlying cell matrix (`modules`). It then prints a small portion of the QR code's visual representation using block characters.
Immediately cease direct GitHub URL dependencies. Replace `qr.js` with a modern, actively maintained QR code library from npm (e.g., `qrcode` or `qrcode.react`).
Avoid using `qr.js` for new projects. Migrate existing projects to a well-maintained alternative. Consider `qrcode` (for Node.js/browser, supports various output formats) or `qrcode.react` (for React applications).
If you must use this package in an ESM context (not recommended), you might need to rely on bundlers or Node.js's CJS-ESM interop features, such as `import * as qr from 'qr.js';`, but this is not guaranteed to work seamlessly or consistently. The best fix is to use an ESM-compatible QR code library.
If you need a library that directly renders QR codes to visual formats (e.g., canvas, SVG, PNG), consider alternatives like `qrcode` (npm package) which offers `toCanvas`, `toDataURL`, `toFile` methods, or `qrcode.react` for React environments.
This package is CommonJS only. Either convert your project to use CommonJS (not recommended for new projects), or use a bundler that handles CJS-ESM interop. The recommended fix is to replace `qr.js` with a modern QR code library that supports ESM.
Call `qr` as a regular function: `const qrcodeData = qr('your input string');`.Ensure `qr.js` is correctly installed via `npm install qr.js`. If you were linking to a GitHub URL, update your dependencies to use the npm package or, preferably, switch to a different, maintained QR code library.
No dependency data recorded yet.