# How we can share data between node-red and another nodejs application

**URL:** <https://discourse.nodered.org/t/how-we-can-share-data-between-node-red-and-another-nodejs-application/37910>\
**Category:** General\
**Created:** [23 December 2020 10:05 UTC](https://discourse.nodered.org/t/how-we-can-share-data-between-node-red-and-another-nodejs-application/37910 "2020-12-23T10:05:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahul1](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@rahul1](https://discourse.nodered.org/u/rahul1)\
**Post date:** [23 December 2020 10:05 UTC](https://discourse.nodered.org/t/how-we-can-share-data-between-node-red-and-another-nodejs-application/37910/1 "2020-12-23T10:05:05Z")

</div>

How we can share nodered data in another nodejs application which is running in the same server.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 December 2020 10:21 UTC](https://discourse.nodered.org/t/how-we-can-share-data-between-node-red-and-another-nodejs-application/37910/2 "2020-12-23T10:21:08Z")

</div>

Hi Rahul.

> [@rahul1](#):
>
> share nodered data in another nodejs application

#### From best to worst (IMO)...

You can use MQTT?

You could do HTTP Requests to/from node-red to/from application.

You could use UDP or TCP socket .io

You could launch the nodejs app with command line parameters.

You could write files from node-red and read them in nodejs app.

_note: there are many more solutions_

TBH, your question is far to open ended.

* * *

questions...

- Do you know how to do MQTT?
- Do you know how to create endpoint in nodejs app?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [23 December 2020 21:48 UTC](https://discourse.nodered.org/t/how-we-can-share-data-between-node-red-and-another-nodejs-application/37910/3 "2020-12-23T21:48:00Z")

</div>

You missed embedding Node-RED in the nodejs app and using UNIX pipes 😃

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 December 2020 21:55 UTC](https://discourse.nodered.org/t/how-we-can-share-data-between-node-red-and-another-nodejs-application/37910/4 "2020-12-23T21:55:30Z")

</div>

... or using a database as the glue

---

<div class="post-metadata">

**Author:** ![rahul1](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@rahul1](https://discourse.nodered.org/u/rahul1)\
**Post date:** [24 December 2020 13:20 UTC](https://discourse.nodered.org/t/how-we-can-share-data-between-node-red-and-another-nodejs-application/37910/5 "2020-12-24T13:20:44Z")

</div>

but I wanted to be more like a event based, but if I use db it won't be rifght?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 December 2020 13:27 UTC](https://discourse.nodered.org/t/how-we-can-share-data-between-node-red-and-another-nodejs-application/37910/6 "2020-12-24T13:27:51Z")

</div>

> [@rahul1](#):
>
> but I wanted to be more like a event based, but if I use db it won't be

Correct. It will not.

Using database was a joke. Look at other suggestions.

MQTT is 100% event based and IMO the best solution (given the limited information at hand)

Perhaps you could answer the questions?...

> [@Steve-Mcl](#):
>
> - Do you know how to do MQTT?
> - Do you know how to create endpoint in nodejs app?

---

<div class="post-metadata">

**Author:** ![superace](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@superace](https://discourse.nodered.org/u/superace)\
**Post date:** [24 December 2020 14:29 UTC](https://discourse.nodered.org/t/how-we-can-share-data-between-node-red-and-another-nodejs-application/37910/7 "2020-12-24T14:29:15Z")

</div>

How about using Redis? Nodered works brilliantly with Redis and if you do a subscription to a Redis channel on your server in nodejs you will probably get an event triggered.

This of course will be depending on installing Redis on the server and uploading the data to Redis.

Nodered is amazing, and Redis is like superman on steroids when it comes to share data.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [24 December 2020 15:33 UTC](https://discourse.nodered.org/t/how-we-can-share-data-between-node-red-and-another-nodejs-application/37910/8 "2020-12-24T15:33:32Z")

</div>

Yes, REDIS will also work. MQTT is very lightweight though (Mosquitto), not sure about redis. and mqtt fits Node-RED's design principles really well since it was designed with it in the first place and one of the key node-red devs also designed and built one of the most popular mqtt libraries.

---

<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:** [22 February 2021 15:33 UTC](https://discourse.nodered.org/t/how-we-can-share-data-between-node-red-and-another-nodejs-application/37910/9 "2021-02-22T15:33:45Z")

</div>

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