Some nodes need to share configuration. For example, the MQTT In and MQTT Out nodes share the configuration of the MQTT broker, allowing them to pool the connection. Configuration nodes are scoped globally by default, this means the state will be shared between flows.
A configuration node is defined in the same way as other nodes. There are two key differences:
category
property is set to config
<input>
elements have ids of node-config-input-<propertyname>
In this example, the node acts as a simple container for the configuration - it has no actual runtime behaviour.
A common use of config nodes is to represent a shared connection to a remote
system. In that instance, the config node may also be responsible for creating
the connection and making it available to the nodes that use the config node. In
such cases, the config node should also handle the close
event
to disconnect when the node is stopped.
Nodes register their use of config nodes by adding a property to the defaults
array with the type
attribute set to the type of the config node.
As with other properties, the editor looks for an <input>
in the edit template
with an id of node-input-<propertyname>
. Unlike other properties, the editor
replaces this <input>
element with a <select>
element populated with the
available instances of the config node, along with a button to open the config
node edit dialog.
The node can then use this property to access the config node within the runtime.
Node-RED: Low-code programming for event-driven applications.
Copyright OpenJS Foundation and Node-RED contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation, please see our Trademark Policy and Trademark List. Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
The OpenJS Foundation | Terms of Use | Privacy Policy | OpenJS Foundation Bylaws | Trademark Policy | Trademark List | Cookie Policy