npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nfc-pcsclite

v1.2.1

Published

Easy reading and writing NFC tags and cards with bindings over PC/SC to access Smart Cards

Readme

nfc-pcsclite

npm CI GitHub contributors GitHub Issues or Pull Requests GitHub License

Cross-platform NFC library for Node.js Read and write NFC tags and smart cards using built-in PC/SC bindings. Works on Linux, macOS, and Windows.


Content

Overview

nfc-pcsclite provides a low-level Node.js interface for NFC operations using PC/SC bindings. It supports automatic card detection, UID reading, and communication with Android HCE devices.

✅ Supports card UID auto-reading

✅ Works with ACR122 USB reader and other PC/SC-compliant devices

✅ Includes native pcsclite bindings

⚠️ If card detection fails, check the Alternative Usage section.


Installation

Requirements

Node.js

Compatible with Node.js 18 or newer.

Build tools

This package includes native bindings built with node-gyp. Ensure you have a C/C++ toolchain installed for your OS. See node-gyp Installation Guide.

PC/SC API

  • macOS / Windows: Already included.

  • Linux / UNIX: Install manually:

apt-get install libpcsclite1 libpcsclite-dev pcscd

Install package

# Using npm
npm install nfc-pcsclite

# Using Yarn
yarn add nfc-pcsclite

NFC Tag Handling Flow

When a tag is detected, the following occurs:

  1. Detects the card standard (TAG_ISO_14443_3 or TAG_ISO_14443_4);
  2. Connects to the card;
  3. Depending on autoProcessing:
    • true (default): automatically retrieves UID or APDU data; or
    • false: triggers card event only, letting you handle transmission manually;
  4. You can then read, write, or send custom commands.

Basic Usage

import { NFC } from 'nfc-pcsc';

const nfc = new NFC(); // optional: pass a logger (e.g. Pino, Winston)

nfc.on('reader', reader => {
  console.log(`${reader.reader.name} device attached`);

  reader.on('card', card => {
    console.log(`${reader.reader.name} card detected`, card);
  });

  reader.on('card.off', card => {
    console.log(`${reader.reader.name} card removed`, card);
  });

  reader.on('error', err => {
    console.error(`${reader.reader.name} error`, err);
  });

  reader.on('end', () => {
    console.log(`${reader.reader.name} device removed`);
  });
});

nfc.on('error', err => {
  console.error('An error occurred', err);
});

Alternative Usage (Manual Processing)

import { NFC } from 'nfc-pcsc';

const nfc = new NFC();

nfc.on('reader', reader => {
  reader.autoProcessing = false;

  console.log(`${reader.reader.name} device attached`);

  reader.on('card', card => {
    console.log(`${reader.reader.name} card inserted`, card);

    // Send custom APDU commands using reader.transmit()
  });
});

Reading & Writing Data

Example with MIFARE Ultralight tag:

reader.on('card', async card => {
  try {
    const data = await reader.read(4, 12);
    console.log('Data read:', data.toString());
  } catch (err) {
    console.error('Error reading data', err);
  }

  try {
    const text = 'Bright minds build code';
    const buffer = Buffer.alloc(12, 0);
    buffer.write(text);
    await reader.write(4, buffer);
    console.log('Data written');
  } catch (err) {
    console.error('Error writing data', err);
  }
});

FAQ

Can I use it in Electron?

Yes. It works with Electron and other Node.js environments that support native modules.

See Electron’s guide on native modules.

Can I use it in Angular + Electron?

Yes. You’ll need to update your package.json and webpack.config.js per this issue comment.

Do I need Babel?

No. The library is already transpiled to support Node.js 18+.

Supported Node.js versions

It supports from the version 18.x to the latest 25.x, including the current LTS on 22.x. Node.js uses the convention of having the even-numbered versions as stable releases and odd-numbered versions having experimental features, but even and odd-numbered version numbers are basically backwards compatible.

Ref: Official Node.js Release Plan

Can I read NDEF tags?

Yes. Use reader.read() and parse the raw bytes with TapTrack/NdefJS.

React Native support?

No. nfc-pcsclite depends on Node.js native bindings and PC/SC APIs, unavailable in mobile runtimes.


Common Issues

Transaction failed using CONNECT_MODE_DIRECT

See explanation.

Authentication Error after Multiple Writes (MIFARE Classic)

See instructions.

Reading Type 4 tags (Elsys sensors)

Set readClass to 0x00 in:

reader.read(blockNumber, length, blockSize, packetSize, 0x00);

See discussion.


Disclaimer

This library revives maintenance over an abandoned project. For a high-level API, see nfc-pcsc.


License

Released under the MIT License.