node-red-node-defaults 1.0.0
Node-RED editor plugin that injects default values into node instances when dropped onto the canvas
node-red-node-defaults
A Node-RED editor plugin that automatically injects default values into node instances when they are dropped onto the canvas.
Defaults are defined once in settings.js and apply to every new node of the configured type — no flow-by-flow setup required.
How it works
The plugin has two parts:
| Part | File | Role |
|---|---|---|
| Server | index.js |
Reads nodeDefaults from settings.js, exposes it via a lightweight HTTP endpoint |
| Editor | index.html |
Fetches the config on load, listens for nodes:add, and injects defaults into each new node instance |
Injection rules (per field)
For each configured field the editor applies these rules in order:
- Field is empty (
null,undefined,'') → inject - Field matches the node type's built-in default → inject (user never changed it)
- Field differs from the built-in default → leave (user set it intentionally)
Credential fields (userid, password, etc.) use rule 1 only — inject if empty, leave if already set.
Existing saved nodes in a flow are never overwritten — injection only applies to nodes added to the canvas after the plugin loads.
Installation
# In your Node-RED user directory (typically ~/.node-red)
npm install node-red-node-defaults
Or during development, link it:
# In this package directory
yarn link
# In your Node-RED user directory
yarn link node-red-node-defaults
Configuration
Add a nodeDefaults object to your Node-RED settings.js. The top-level keys are node type names exactly as registered (e.g. 'e-mail', not the package name).
// settings.js
module.exports = {
// ... other settings ...
nodeDefaults: {
// Outbound SMTP (node-red-node-email)
'e-mail': {
server: 'smtp.example.com',
port: '587',
secure: false, // false = STARTTLS on 587; true = TLS on 465
tls: false,
authtype: 'BASIC',
userid: '[email protected]', // credential field
password: 'yourpassword' // credential field
},
// Inbound IMAP/POP3 (node-red-node-email)
'e-mail in': {
protocol: 'IMAP',
server: 'imap.example.com',
port: '993',
useSSL: true,
autotls: 'never', // 'never' | 'required' | 'always'
box: 'INBOX',
disposition: 'Read', // 'None' | 'Read' | 'Delete'
criteria: 'UNSEEN',
repeat: '300'
}
}
}
Finding the correct field names
Field names must match what the node type declares in its defaults or credentials block. The easiest way to find them:
- Open the Node-RED editor
- Drop the node onto the canvas
- Open Browser DevTools → Network →
/nodes - Find the node's HTML file and look at
RED.nodes.registerType('type-name', { defaults: { ... }, credentials: { ... } })
Security note
Credential values (e.g. userid, password) set in settings.js are returned in plaintext from the /node-defaults/config endpoint to any authenticated browser session that can reach the Node-RED editor. Ensure your Node-RED instance is not publicly accessible when using credential defaults.
Contact
- Author: William Shostak (https://github.com/wshostak)
License
This project is licensed under the ISC License — see the LICENSE file for more details.
Copyright (c) 2026 William Shostak