How does one persist data in electron


#1

In my electron app I want to persist some data locally e.g. user data, list of file paths, configuration data.
How can I do that, any minimalist approach for the same. I would prefer to save data in a nosql kind of database.


#2

LocalStorage/IndexedDB is always a quick and easy way of storing smaller amounts of info. You could always just write a quick JSON file using fs too. It depends how much information you’re storing though, and whether it’s worth the overhead of a whole database system for just a few bits of configuration.


#3

You can use Browser APIs such as HTML5 local storage and IndexedDB but also the Node.js supported mechanisms for data persistence such as NeDB, RxDB , PouchDB. For advanced data requirements you can use large scale database systems such as MySQL, MongoDB etc. Check a complete list of available methods to persist data in Electron apps


#4

Thanks @caffiend @techiediaries for the response.
I was storing a lot of data, used nedb : https://github.com/louischatriot/nedb
It works very well, only thing that is missing is encryption. Thinking of handling it myself, is there anything that can save me time of building and maintaining it?


#5

Check out electron-store. We’re about to add encryption support.