electron-userland/electron-json-storage is a JavaScript project with 1.4k stars. :package: Easily write and read user settings in Electron apps
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Easily write and read user settings in Electron apps
Electron lacks an easy way to persist and read user settings for your application. electron-json-storage implements an API somewhat similar to localStorage to write and read JSON objects to/from the operating system application data directory, as defined by app.getPath('userData').
Related modules:
electron-settings
electron-store
electron-storage
Installation
Install electron-json-storage by running:
$ npm install --save electron-json-storage
You can require this module from either the main or renderer process (with and without remote).
Running on Electron >10 renderer processes
When loaded in renderer processes, this module will try to make use of
electron.remote in order to fetch the userData path.
Electron 10 now defaults enableRemoteModule to
false,
which means that electron-json-storage will be able to calculate a data path by default.
The solution is to manually call storage.setDataPath() before reading or
writing any values or setting enableRemoteModule to true.
Documentation
storage
.getDefaultDataPath() ⇒ String | Null
.setDataPath(directory)
.getDataPath() ⇒ String
.get(key, [options], callback)
.getSync(key, [options])
.getMany(keys, [options], callback)
.getAll([options], callback)
.set(key, json, [options], callback)
.has(key, [options], callback)
.keys([options], callback)
.remove(key, [options], callback)
.clear([options], callback)
storage.getDefaultDataPath() ⇒ String | Null
This function will return null when running in the
renderer process without support for the remote IPC
mechanism. You have to explicitly set a data path using
.setDataPath() in these cases.
Kind: static method of storage Summary: Get the default data path Returns: String | Null - default data path Access: public Example
If the key doesn't exist in the user data, an empty object is returned.
Also notice that the .json extension is added automatically, but it's
ignored if you pass it yourself.
Passing an extension other than .json will result in a file created
with both extensions. For example, the key foo.data will result in a file
called foo.data.json.
Kind: static method of storage Summary: Read user data Access: public
Kind: static method of storage Summary: Check if a key exists Access: public
Param
Type
Description
key
String
key
[options]
Object
options
[options.dataPath]
String
data path
callback
function
callback (error, hasKey)
Example
const storage = require('electron-json-storage');
storage.has('foobar', function(error, hasKey) {
if (error) throw error;
if (hasKey) {
console.log('There is data stored as `foobar`');
}
});
storage.keys([options], callback)
Kind: static method of storage Summary: Get the list of saved keys Access: public
Param
Type
Description
[options]
Object
options
[options.dataPath]
String
data path
callback
function
callback (error, keys)
Example
const storage = require('electron-json-storage');
storage.keys(function(error, keys) {
if (error) throw error;
for (var key of keys) {
console.log('There is a key called: ' + key);
}
});
storage.remove(key, [options], callback)
Notice this function does nothing, nor throws any error
if the key doesn't exist.
Kind: static method of storage Summary: Remove a key Access: public
How active is development on electron-userland/electron-json-storage?
The most recent commit recorded on electron-userland/electron-json-storage was 3.4 years ago, based on the GitHub push timestamp. The repository has 74 forks — one of the better signals of community interest.
How many stars does electron-userland/electron-json-storage have?
electron-userland/electron-json-storage has 1.4k GitHub stars — refresh the page for the live number, or check github.com/electron-userland/electron-json-storage. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is electron-userland/electron-json-storage written in?
electron-userland/electron-json-storage is written primarily in JavaScript. GitHub's language field is based on the largest share of bytes in the default branch.
What topics is electron-userland/electron-json-storage associated with?
GitHub's repository topics for electron-userland/electron-json-storage: "electron", "json", "settings", "storage". TopGit's editorial category is open-source.
Where do I read more about electron-userland/electron-json-storage?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/electron-userland/electron-json-storage is the definitive source.
Read full README in the tab above.
Is electron-json-storage worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of electron-json-storage.