# Creating nodes - class concept

**URL:** <https://discourse.nodered.org/t/creating-nodes-class-concept/73035>\
**Category:** Developing Nodes\
**Created:** [1 January 2023 21:39 UTC](https://discourse.nodered.org/t/creating-nodes-class-concept/73035 "2023-01-01T21:39:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![agmacedo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/agmacedo/32/31119_2.png) [@agmacedo](https://discourse.nodered.org/u/agmacedo)\
**Post date:** [1 January 2023 21:39 UTC](https://discourse.nodered.org/t/creating-nodes-class-concept/73035/1 "2023-01-01T21:39:15Z")

</div>

What is the best way to create new nodes and use it in Node-red app. Something like the class concepts in c#. My idea is to create a node to use as a template in different situations, like a form data enter to transfer data to PLC. It should be possible to define the connect communication and use it as a recipe.  
Thanks

---

<div class="post-metadata">

**Author:** ![tve](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tve/32/59475_2.png) [@tve](https://discourse.nodered.org/u/tve)\
**Post date:** [2 January 2023 00:01 UTC](https://discourse.nodered.org/t/creating-nodes-class-concept/73035/2 "2023-01-02T00:01:31Z")

</div>

You can easily use the javascript classes to define your nodes, for example:

```auto
module.exports = function(RED) {

  class flexdashCtrl {
    // config: name, fd_container
    constructor(config) {
      RED.nodes.createNode(this, config)

...

      this.on("input", msg => {

...

  }
}

```

But I'm not sure that's what you were asking about?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [2 January 2023 00:17 UTC](https://discourse.nodered.org/t/creating-nodes-class-concept/73035/3 "2023-01-02T00:17:07Z")

</div>

uibuilder makes extensive use of shared classes - specifically single-instance classes. It also uses at least 1 external package for a standardised event-handling class. Though it doesn't go as far as defining the node itself as a class but rather uses a restructured set of functions that makes defining more complex nodes a lot easier and enables easier parsing of the different elements. I've used those principals in a number of nodes now.

---

<div class="post-metadata">

**Author:** ![agmacedo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/agmacedo/32/31119_2.png) [@agmacedo](https://discourse.nodered.org/u/agmacedo)\
**Post date:** [2 January 2023 02:25 UTC](https://discourse.nodered.org/t/creating-nodes-class-concept/73035/4 "2023-01-02T02:25:36Z")

</div>

Where I can find some documentation and samples ?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [2 January 2023 14:14 UTC](https://discourse.nodered.org/t/creating-nodes-class-concept/73035/5 "2023-01-02T14:14:41Z")

</div>

For uibuilder? The GitHub repo: [GitHub - TotallyInformation/node-red-contrib-uibuilder: Easily create data-driven web UI's for Node-RED using any (or no) front-end library.](https://github.com/TotallyInformation/node-red-contrib-uibuilder)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 March 2023 14:14 UTC](https://discourse.nodered.org/t/creating-nodes-class-concept/73035/6 "2023-03-03T14:14:59Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
