Skip to content
Program NFC with JavaScript! A Node.js addon for HAL NFC.
C++ JavaScript Python C
Branch: master
Clone or download
Latest commit c9e6dff Nov 5, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Minor edits Sep 9, 2019
hal_nfc_wrapper Set function now uses Nan Nov 5, 2019
.gitignore Added boilerplate files Jul 12, 2019
LICENSE Added boilerplate files Jul 12, 2019 Update Sep 15, 2019
binding.gyp Added ndef types folder Aug 26, 2019
index.js Cleanup Sep 6, 2019
package-lock.json Version change Sep 14, 2019
package.json Upgrade version Nov 5, 2019


MATRIX Lite NFC JS is an npm package that allows users of varying skill levels to easily program NFC with their MATRIX Creator.

Smartphone Apps For Debugging


  • Reading Info (All tags)
  • Reading Pages (MIFARE Ultralight & NTAG)
  • Writing Page (MIFARE Ultralight & NTAG)
  • Reading NDEF (MIFARE Ultralight & NTAG)
  • Writing NDEF (MIFARE Ultralight & NTAG)


  1. Install matrix-hal-nfc to use this library.

  2. Download and install the latest version of Node.js, using nvm (Node Version Manager)

curl -o- | bash
. ~/.bashrc
nvm install node

mkdir myApp
cd myApp
npm init -y
  1. Install matrix-lite-nfc-js
npm install @matrix-io/matrix-lite-nfc --save


View the examples folder!


Import Statement

const nfc = require("@matrix-io/matrix-lite-nfc");


When a read or write function completes, it will return a status code to indicate the result. nfc.Status returns a string of what that number means.


There can only be one instance of NFC reading. This is a hardware limitation that will not change.

Starting Read Loop

// Configure what you want to read
let options = {
    rate: 100,   // Read loop speed (Milliseconds)
    // At least 1 read options is required. Less options -> faster reading!
    info: true,  // Generic information for any NFC tag
    pages: true, // All page data
    page: 0,     // A single page(faster than pages)
    ndef: true   // All NDEF data

// Start the loop, (code, tag) => {
    // code: NFC activation status
    // tag : Object with requested NFC data

Stopping Read Loop;


An NFC constructor that represents an NDEF message. There are 2 uses for this class.

1. Creating a new NDEF Message

// Create an empty NDEF message
let msg = new nfc.message();

// Add NDEF Records to message
msg.addTextRecord("Hello World");
msg.addTextRecord("Hola Mundo", "es");
msg.addMimeMediaRecord("text/json", '{"answer": 42}');

// You then pass msg into nfc.write.message(msg);

2. Reading an existing NDEF Message{ndef:true}, (code, tag) => {
    // You can create a new NDEF message from a scanned tag.
    msg = new nfc.message(tag.ndef.content);

    // Once created, you can read any known NDEF record.
    // or

    // You see the number of records with
    // msg.getRecordCount();


Writing to an NFC tag should normally be done inside the read loop.

Writing an NDEF message

let msg = new nfc.message();

    // codes.activation : NFC activation status
    // codes.write      : NFC write status

Erasing an NDEF message

    // codes.activation : NFC activation status
    // codes.write      : NFC write status

Writing to a tag's page (WARNING)

Be careful when writing to a page. You can accidentally lock your NFC tag!

let page_index = 25;            // page you want to overwrite
let page_byte = [48,45,59,21];  // Array of numbers that represents a byte, page_byte).then((code)=>{
    // codes.activation : NFC activation status
    // codes.write      : NFC write status

Building Locally For Development

Download the repository.

git clone

Install all dependencies.

npm install

You can now import the module into any .js file.

const nfc = require("./PATH_TO_NFC_JS");

Use the following command when you need to compile any new C++ changes.

npm run build
You can’t perform that action at this time.