Hi guys, I'm new to Node-RED so this is probably a dumb question, but I was wondering if it's possible to create custom nodes that run on the client side? By that I mean, that the JavaScript code would run in the browser.
I need this because I want to create nodes that interact with the browser.
Hi Derek,
I 'think' there are currently a couple of ways of achieving this, depending on your use case:
-
In the Node-RED dashboard: recently version 2.10.0 of the Node-RED dashboard was released, which offers a Widget API. That can be used to create your own widget in the dashboard. In the .js file, there is a HTML function where you can generate Javascript code (as a string) that will run in the browser.
-
In the Node-RED flow editor: every Node-RED node can have Javascript that runs in the browser (as defined in it's .html file), but that is - I think - only active when you have the node's config screen open.
Perhaps you can explain a bit more what you are trying to build ...
Have a look at my node-red-contrib-uibuilder node. That makes client code available as a library as well as server code.
You will need to understand how the web servers work that Node-RED creates.