Currently I'm developing an application using vue.js (MEVN)
I need to implement CoAP and OPC-UA client in vue.js Unfortunately, I can't find a suitable client library for vue.js But, I did found the library for node.js.
So, this pop up a question to me, is it possible to use the node.js library to vue.js ?
For example:
My guess, it is not... But they have the same language. So, I'm really not sure.
Please share your thought about this, or any other possible library if existed that can be used with vue.js
Thank you !
Vue.js can use NPM library, i.e. a library that was published on NPM registry and is installed with NPM or Yarn package managers.
There's no strict definition of Node library. Usually this means that a library is intended to be used in Node.js and uses Node.js features. Sometimes it's possible to mock or polyfill them on client side (streams, buffers). Package internals should be examined in order to make a decision. E.g. joi is Node library but doesn't depend on Node.js features for the most part and is suitable for browser use with a few adjustments at build step.
node-coap
documentation clearly states that the package uses Node.js http
module, which isn't available on client side:
client and server library for CoAP modeled after the http module
Notice that it refers to CoAP client, not to client-side environment (a browser).
Since Vue.js supports server-side rendering, it's possible to use Node libraries on server side. This will work if some units don't need to be used on client side or they are used differently (load data from filesystem on server side and via AJAX request on client side). This approach won't work in this case because Node.js library functionality is needed on client side.