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

snap7-node-addon-api

v0.1.7

Published

Asynchronous Node-API bindings for the Snap7 S7 client

Readme

snap7-node-addon-api

An asynchronous, Promise-based Node.js binding for the essential Snap7 S7Client operations. Snap7 is compiled into the native addon from vendored source; no system-wide Snap7 installation is required.

Supported build targets:

  • Linux x64 and ARM64
  • Windows x64
  • Node.js 22 or newer

Requirements

Linux requires Python 3, make, and a C++17 compiler. On Debian/Ubuntu:

sudo apt install build-essential python3

Windows requires Python 3 and Visual Studio 2022 Build Tools with the Desktop development with C++ workload.

Build and test

npm install
npm test

To force a clean native rebuild:

npm run clean
npm run build

Usage

const { S7Client, Area, WordLen } = require('snap7-node-addon-api');

async function run() {
  const client = new S7Client();

  try {
    await client.connectTo('192.168.0.1', 0, 2);

    const input = await client.dbRead(1, 0, 16);
    console.log(input);

    await client.dbWrite(1, 4, Buffer.from([0x00, 0x2a]));

    const markers = await client.readArea(
      Area.MK,
      0,
      0,
      8,
      WordLen.Byte
    );
    console.log(markers);
  } catch (error) {
    console.error(error.code, error.message);
  } finally {
    await client.disconnect();
  }
}

run();

Calls made on one S7Client instance execute in invocation order. Native network work runs outside the Node.js event loop. Different client instances can operate concurrently.

API

new S7Client()

Creates an independent native Snap7 client.

client.connectTo(address, rack = 0, slot = 2)

Connects to a PLC using an IPv4 address and resolves with no value. Rejects with a Snap7Error whose numeric Snap7 code is available as error.code.

client.disconnect()

Disconnects the client.

client.dbRead(dbNumber, start, size)

Reads size bytes and resolves to a Node.js Buffer.

client.dbWrite(dbNumber, start, data)

Writes a Buffer or Uint8Array.

client.readArea(area, dbNumber, start, amount, wordLen)

Reads a raw Snap7 area. The returned buffer size is amount multiplied by the selected word length. Snap7 permits only one item for WordLen.Bit; for bits, start is a bit address.

client.writeArea(area, dbNumber, start, wordLen, data)

Writes a raw area. amount is inferred from data.length / word size.

client.connected

Returns the last connection state observed by the native client.

errorText(code)

Formats a numeric Snap7 client error code.

PLC notes

  • S7-300/400 commonly use rack 0, slot 2.
  • S7-1200/1500 commonly use rack 0, slot 1.
  • PUT/GET access must be enabled in the PLC configuration where required.
  • Optimized DB access may need to be disabled for absolute DB addressing.

Licensing

The binding is MIT-licensed. The vendored Snap7 source remains under LGPL-3.0 or later. See THIRD_PARTY_NOTICES.md and vendor/snap7/lgpl-3.0.txt before distributing binaries.