SDK · Node.js / TypeScript

OPC UA in Node.js / TypeScript

node-opcua is a complete OPC UA implementation in TypeScript: client, server, discovery and aggregation. MIT-licensed, which makes it the easiest stack to embed commercially, and it runs in a browser as well as on Node.

Projectnode-opcua
Version2.181.1
LicenceMIT
Installnpm install node-opcua

What to know before you start

  • Node.js 20 or newer.
  • MIT licence, so no copyleft question when embedding it in a product.
  • Client and server are both first-class, so you can build a gateway with one dependency.
  • The type definitions are thorough: worth using TypeScript here even if the rest of your project is JavaScript.
  • Commercial support and training exist from Sterfive, who maintain it. Certifiable builds are a paid tier.

Command-line tools it ships

opcua-commander

Recipes

The same twelve tasks, in this stack, pinned to the version above. Each one runs against a free public server.

TaskWhat it does
Connect to an OPC UA server in Node.jsCreate a client, connect the transport, then create a session. node-opcua separates those two steps deliberately, and you must clo
Browse an OPC UA address space in Node.jsCall browse on a node and read the references it returns. Each reference carries the browse name, node class and type definition,
Read a value from an OPC UA server in Node.jsRead the Value attribute and inspect the whole DataValue that comes back. The status code and both timestamps are on the object, a
Write a value to an OPC UA server in Node.jsBuild a DataValue whose dataType matches the node exactly, then check the returned status code. The umati sample server accepts wr
Subscribe to data changes in Node.jsCreate a subscription with the publishing interval your consumer needs, then monitor items with their own sampling interval, queue
Call an OPC UA method in Node.jsCall takes the owning object's node id, the method's node id and an array of typed input arguments. The result carries its own sta
Set up OPC UA certificates in Node.jsnode-opcua manages a PKI directory for you. Point it at a folder, set your ApplicationUri to match the certificate's SAN, and choo
Decode custom structures in Node.jsnode-opcua reads the server's DataTypeDefinitions and can construct extension objects for you. Get the type's constructor from the
Read historical data in Node.jsreadHistoryValue takes a node and a bounded time range. Check the server claims a historical access facet first, and prefer server
Subscribe to alarms and events in Node.jsMonitor the EventNotifier attribute of the Server object with an event filter that selects the fields you need. Selecting server-s
Bridge OPC UA to MQTT in Node.jsnode-opcua is a client-server stack, so the practical pattern is to subscribe over client-server and republish to MQTT. Carry the
Handle errors and reconnect in Node.jsConfigure the built-in connectionStrategy and listen for the client's lifecycle events. node-opcua will re-establish the session a

Last verified 7 September 2026 against OPC UA 1.05.07. Version read from the project release tags. OPC UA Connect is an educational resource and is not affiliated with the OPC Foundation.

Free download
OPC UA Troubleshooting & Integration Checklist
The field-tested checklist engineers use to diagnose certificates, ports and namespace problems fast, plus a Python (asyncua) client template.
Get the free checklist →
Free, no course, no login