Skip to content

Commit c890cfe

Browse files
authored
Merge pull request #273 from dgilleland/patch-1
Document built-in environment variables
2 parents dd8c001 + 4ed54c3 commit c890cfe

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/user-guide/environment-variables.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,24 @@ function:
6060
let foo = env.get("FOO");
6161
```
6262

63+
### Built-In Environment Variables
64+
65+
*Since Node-RED 2.2*
66+
67+
Node-RED maintains its own set of environment variables for exposing information about the node itself. This information helps "locate" the node in your [workspace](/docs/user-guide/editor/workspace/index.md). Nodes in your workspace exist as part of a [flow](/docs/user-guide/editor/workspace/flows.md). Likewise, a node may (or may not) be part of a [group](/docs/user-guide/editor/workspace/groups.md). Nodes, flows and groups are each given unique IDs that are generated by Node-RED.
68+
69+
Nodes, flows and groups all support the `name` property, which you can change when [editing properties](/docs/user-guide/editor/workspace/nodes.md#editing-node-properties).
70+
71+
The following environment variables can be used to access this contextual information for the node.
72+
73+
- `NR_NODE_ID`
74+
- `NR_NODE_NAME`
75+
- `NR_GROUP_ID`
76+
- `NR_GROUP_NAME`
77+
- `NR_FLOW_ID`
78+
- `NR_FLOW_NAME`
79+
80+
Note that while the IDs generated by Node-RED are guaranteed to be unique, the names are not. If a node, flow or group is not given a name, then the corresponding environment variable will return an empty string. If a node is not part of a group, its group id environment variable will also return an empty string.
6381

6482
### Subflow Instance properties
6583

0 commit comments

Comments
 (0)