# Exposing settings to the editor

**URL:** <https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882>\
**Category:** Developing Nodes\
**Created:** [14 September 2020 15:19 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882 "2020-09-14T15:19:17Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)\
**Post date:** [14 September 2020 15:19 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882/1 "2020-09-14T15:19:17Z")

</div>

[Exposing settings to the editor](https://nodered.org/docs/creating-nodes/node-js#exposing-settings-to-the-editor)  
Can anybody clarify this feature by answering a few of my questions? Please type slowly and assume I know nothing. 🤓

1. Does adding this feature give me a global setting shared between my nodes?

2. Is there an interface somewhere that allows a user to edit the settings.js file or is that done manually?

3. Setting `exportable: true` allows the user to override my value with a value set in settings.js or does that do something else?

4. Can I access this value in my node's settings page and change it there and will that use the normal validation lifecycle?

5. And most importantly, do you have any real world examples of where and why this would be used? Any public repos that take advantage of this feature?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 September 2020 15:46 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882/2 "2020-09-14T15:46:34Z")

</div>

Hi

1. 
  - Yes.

2. 
  - No. Currently done manually as being js it can contain hard to parse/format/verify code.

3. 
  - Yes - that is the purpose.

4. 
  - Yes you can access - but generally not set by the page as that is what settings.js does for you.

5. 
  - see [https://github.com/node-red/node-red/blob/master/packages/node\_modules/%40node-red/nodes/core/network/05-tls.js#L84](https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/nodes/core/network/05-tls.js#L84) and [https://github.com/node-red/node-red/blob/master/packages/node\_modules/%40node-red/nodes/core/network/05-tls.html#L166](https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/nodes/core/network/05-tls.html#L166)

---

<div class="post-metadata">

**Author:** ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)\
**Post date:** [14 September 2020 16:20 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882/3 "2020-09-14T16:20:48Z")

</div>

Thank you for that fast clarification. That leaves me with 1 final question when it comes to utilizing the setting. I see that it is easily accessible in the node's settings editor as RED.settings.myNodeSomeSetting. I am missing the docs showing how to access it on the backend. Can you enlighten me, please? Thanks for the tutelage.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 September 2020 16:25 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882/4 "2020-09-14T16:25:28Z")

</div>

It should be the same... RED.settings.myNodeSomeSetting

---

<div class="post-metadata">

**Author:** ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)\
**Post date:** [14 September 2020 16:30 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882/5 "2020-09-14T16:30:38Z")

</div>

Thanks. That was the first thing I tried and get `undefined` each time. I must be doing something wrong. I though maybe there was a getter method on the settings object that I was failing to find.

p.s. I am pretty sure I am atleast setting it correctly, because I can see the value in `oneditprepare` .

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 September 2020 16:35 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882/6 "2020-09-14T16:35:27Z")

</div>

You are setting it in settings.js ? (and restarting Node-RED)

---

<div class="post-metadata">

**Author:** ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)\
**Post date:** [14 September 2020 16:37 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882/7 "2020-09-14T16:37:57Z")

</div>

Only setting it in the registerType function, not in the setting.js

```auto
RED.nodes.registerType(NODE_TYPE, UiMp4FragNode, {
    settings: {
      uiMp4fragHlsJsSource: { value: HLS_JS_SOURCE, exportable: true }
    }
  });

```

I ensured that the naming format complied with the warning. Constantly reboot server after I edit.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [14 September 2020 16:38 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882/8 "2020-09-14T16:38:53Z")

</div>

A couple clarifications to Dave's replies

> [@kevinGodell](#):
>
> Setting `exportable: true` allows the user to override my value with a value set in settings.js or does that do something else?

All of the settings can be set by the user via their `settings.js` file. The `exportable` flag determines whether that setting is exposed in the editor as well as the runtime.

But the value should be considered **read-only**.

> [@kevinGodell](#):
>
> Can I access this value in my node's settings page and change it there and will that use the normal validation lifecycle?

If you have set `exportable` to `true`, then yes, you can access the value in the edit dialog of your node. But you cannot change its value from there.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [14 September 2020 16:42 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882/9 "2020-09-14T16:42:30Z")

</div>

> [@kevinGodell](#):
>
> `NODE_TYPE`

What is the value of `NODE_TYPE` here?

---

<div class="post-metadata">

**Author:** ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)\
**Post date:** [14 September 2020 16:45 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882/10 "2020-09-14T16:45:33Z")

</div>

Sorry, I defined some const because I am making my boiler plate code for my nodes structured as classes.

```auto
const HLS_JS_SOURCE = 'https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.light.min.js';

const NODE_TYPE = 'ui_mp4frag';

```

node-red gave me that warning that my settings must beging with `uiMp4frag`. then i changed it to comply and it stopped warning me.

---

<div class="post-metadata">

**Author:** ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)\
**Post date:** [14 September 2020 17:42 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882/11 "2020-09-14T17:42:01Z")

</div>

Ok. I think I misunderstood the api. If I want the setting available in my backend node constructor as RED.settings.myNodeMySetting, then it must be defined in the settings.js or it will be undefined. If I want to make it available to the settings page, then I have to also add it when using registerType. I thought that the backend could access the default value set during registerType. Sorry for the confusion.

What I have gathered is that I can check if the setting is defined from settings.js before registerType is called. I can update the value and make it visibile in the settings dialog page as informational showing the user which lib is being used along with instructions to edit it in settings.js and reboot the server.

---

<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:** [13 November 2020 17:42 UTC](https://discourse.nodered.org/t/exposing-settings-to-the-editor/32882/12 "2020-11-13T17:42:42Z")

</div>

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