# Where to save persistent data in a published node

**URL:** <https://discourse.nodered.org/t/where-to-save-persistent-data-in-a-published-node/59544>\
**Category:** Developing Nodes\
**Created:** [8 March 2022 15:57 UTC](https://discourse.nodered.org/t/where-to-save-persistent-data-in-a-published-node/59544 "2022-03-08T15:57:38Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [9 March 2022 19:56 UTC](https://discourse.nodered.org/t/where-to-save-persistent-data-in-a-published-node/59544/21 "2022-03-09T19:56:33Z")

</div>

The easiest way of working (for our users) imho would be that you store the json tree in the flow.json file, as a config node property. Because the eveything works out of the box, like they are used to do.

However, whether or not you can store the json tree in the config node seems to me dependent on how we need to update that static config that is not related to ui nodes (i.e. position of the widgets, and then the config of panels, grids, tabs, ...):

1. If you need to use an isolated external layout manager, then you need the update the flow via the server side. I have not done that yet, but I assume that is what Nick means with the admin http api above?

2. If you can somehow integrate a layout manager into the config node's config screen, then a user can use that to change the config node properties. Once done, he can deploy the flow (and the config node changes), and from here on it all works out of the box automatically.

For me option 2 would be the most user friendly, but completely no idea whether something like that is possible.

Hopefully this makes a bit sense...

---

<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:** [9 March 2022 21:24 UTC](https://discourse.nodered.org/t/where-to-save-persistent-data-in-a-published-node/59544/22 "2022-03-09T21:24:00Z")

</div>

> [@BartButenaers](#):
>
> > [@tve](#):
> >
> > There's also size & position of the widgets
> 
> I thought that this was info that you needed to calculate on the fly, without storing it... And isn't that dependent on the client (screen size,...) in a responsive framework?

The layout is a grid (like the current dashboard), so each widget has a width and height in grid units, just like in the current dashboard.

> [@BartButenaers](#):
>
> Ah yes, I had completely forgotten about those. Of course you need to store that info somewhere. Personally it seems to me that this can be stored - as config node properties - in the flow.json file. Because the config nodes are 1-to-1 related to a dashboard.

Yes, that's correct. But for export/import to work correctly I have to do the same thing the dashboard currently does, which is to have fd-panel, fd-grid, and fd-tab config nodes (equiv to the ui\_group and ui\_tab config nodes. To do that I have to invert my data structure: right now a grid has an array of widget IDs, and instead each widget will need to have the ID of the grid that contains it, and like that up the tree. Not the end of the world, but more than `JSON.dump`...

> [@BartButenaers](#):
>
> If you can somehow integrate a layout manager into the config node's config screen

Right now I'm not a fan of that idea anymore. I'd like to spend my effort on improving the live layout editing in the dashboard directly. That's such a better experience. The result can be stored in the flow. All I need to do to fit the NR model is to keep such edits in memory until the user clicks on a 'save layout' button, or perhaps I can hook into the deploy button...

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [9 March 2022 22:55 UTC](https://discourse.nodered.org/t/where-to-save-persistent-data-in-a-published-node/59544/23 "2022-03-09T22:55:25Z")

</div>

> [@tve](#):
>
> live layout editing in the dashboard directly

Sounds better indeed. Good luck with your developments!!

---

<div class="post-metadata">

**Author:** ![berijan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/berijan/32/35313_2.png) [@berijan](https://discourse.nodered.org/u/berijan)\
**Post date:** [13 March 2022 07:09 UTC](https://discourse.nodered.org/t/where-to-save-persistent-data-in-a-published-node/59544/24 "2022-03-13T07:09:05Z")

</div>

This may help you

> **[node-red-contrib-persist](https://flows.nodered.org/node/node-red-contrib-persist)**
>
> A node-red node to persist data between Node Red deploys and restarts.

> [@A guide to understanding 'Persistent Context'](https://discourse.nodered.org/t/a-guide-to-understanding-persistent-context/4115):
>
> This is something I wrote up after playing with the context options. I've filed a PR with some of this added to the Node-RED documentation but thought I'd release it here also. I hope people find it useful. Paul A guide to understanding 'Persistent Context' Prior to Node-RED v0.19.0, data could be stored in context as a global, flow or node. This was stored in memory and would be reset with a restart of Node-RED. As of v.0.19.0 you can now store node, flow and global context data in memory O…

[https://nodered.org/docs/user-guide/context](https://nodered.org/docs/user-guide/context)

---

<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:** [12 May 2022 07:09 UTC](https://discourse.nodered.org/t/where-to-save-persistent-data-in-a-published-node/59544/25 "2022-05-12T07:09:48Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/where-to-save-persistent-data-in-a-published-node/59544.md?page=1)
