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.
| Project | node-opcua |
|---|---|
| Version | 2.181.1 |
| Licence | MIT |
| Install | npm 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.
| Task | What it does |
|---|---|
| Connect to an OPC UA server in Node.js | Create 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.js | Call 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.js | Read 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.js | Build 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.js | Create 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.js | Call 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.js | node-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.js | node-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.js | readHistoryValue 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.js | Monitor 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.js | node-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.js | Configure 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.