lyyka
lyyka

Reputation: 560

How to integrate NodeJS web server with Electron?

I am pretty much new to Electron and want to understand basic concepts how to make fully functioning desktop app with it.

I've used vue-cli to create new vue project and just added Electron to the project. The app runs as it should. Now, I want to have functionality, i.e. save todos in a database. For that I would need a web server that would receive a request, store data in database and return some sort of response.

From the architectural point, I want to know what's the best thing to do here? Do I just go and create totally separate node-js app that will serve as a server, while Electron app will just send API calls to it, or is it something else?

EDIT

I am aware I can store data in a local variable, but I want to be able to keep the data after app closes and so on.

Upvotes: 0

Views: 388

Answers (2)

mrvnklm
mrvnklm

Reputation: 1828

As long as your data just has to exist locally and while your application is installed, you could just use persistant store on electron by using electron-store.

If you plan on sharing to do's or have some sync functionality involved, you have to do the "normal way" by sending requests to an typical api / webserver backend. I would recommend using an app friendly and easy to use backend framework like Parse or if looking for a cloud service Google Firebase should fit your needs as the free tier is less data / request intensive apps for the beginning.

Upvotes: 1

Quentin
Quentin

Reputation: 943099

Since you want to persist data across multiple devices you should build a completely separate web service that the app can call.

Upvotes: 1

Related Questions