Documentation question: examples directory

I just had a quick look at the Coursera course "A Developer's guide to Node-RED" (very good, BTW) and learned something new about distributing contributed nodes. Apparently, putting sample flows into a directory named "examples" causes them to appear in the import menu under examples/your-node-name. (I haven't tried this yet but assume it works.) This is a nice feature that I have not seen mentioned elsewhere in the documentation. Few node developers seem to use it, so I thought I should spread the word.

4 Likes

You are absolutely right and people probably should use this more.

For myself, I added some examples in the recent update to node-red-contrib-moment. I will try to add some for the next update to node-red-contrib-uibuilder as well.

The nice thing is that they are really easy to do. Select the nodes you want as the example, then either - export to clipboard, create a file and paste. Or export to library then move the file that is created for you from your userDir to your node's folder.

If creating example flows, best to give them names that clearly reflect their purpose; include a comment node to explain what is going on and any prerequisites; make them standalone so the example works straight away (if possible).

You can also create sub-folders in the examples folder to further categorise the example flows.

2 Likes