Simple config handling for your Electron app or module
Electron doesn't have a built-in way to persist user settings and other data. This module handles that for you, so you can focus on building your app. Config is saved in a JSON file in app.getPath('userData')
.
You can use this module directly in both the main and renderer process.
$ npm install --save electron-config
const Config = require('electron-config');
const config = new Config();
config.set('unicorn', 'π¦');
console.log(config.get('unicorn'));
//=> 'π¦'
// use dot-notation to access nested properties
config.set('foo.bar', true);
console.log(config.get('foo'));
//=> {bar: true}
config.delete('unicorn');
console.log(config.get('unicorn'));
//=> undefined
Returns a new instance.
Type: Object
Default config.
Type: string
Default: config
Name of the config file (without extension).
This is useful if you want multiple config files for your app. Or if you're making a reusable Electron module that persists some config, in which case you should not use the name config
.
You can use dot-notation in a key
to access nested properties.
The instance is iterable
so you can use it directly in a forβ¦of
loop.
Set an item.
Set multiple items at once.
Get an item.
Check if an item exists.
Delete an item.
Delete all items.
Get the item count.
Get all the config as an object or replace the current config with an object:
conf.store = {
hello: 'world'
};
Get the path to the config file.
- electron-debug - Adds useful debug features to your Electron app
- electron-context-menu - Context menu for your Electron app
- electron-dl - Simplified file downloads for your Electron app
- conf - Simple config handling for your app or module
MIT Β© Sindre Sorhus