1 # configstore [![Build Status](https://travis-ci.org/yeoman/configstore.svg?branch=legacy-v3)](https://travis-ci.org/yeoman/configstore)
3 > Easily load and persist config without having to think about where and how
5 Config is stored in a JSON file located in `$XDG_CONFIG_HOME` or `~/.config`.<br>
6 Example: `~/.config/configstore/some-id.json`
8 *If you need this for Electron, check out [`electron-store`](https://github.com/sindresorhus/electron-store) instead.*
14 const Configstore = require('configstore');
15 const pkg = require('./package.json');
17 // create a Configstore instance with an unique ID e.g.
18 // Package name and optionally some default values
19 const conf = new Configstore(pkg.name, {foo: 'bar'});
21 console.log(conf.get('foo'));
24 conf.set('awesome', true);
25 console.log(conf.get('awesome'));
28 // Use dot-notation to access nested properties
29 conf.set('bar.baz', true);
30 console.log(conf.get('bar'));
33 conf.delete('awesome');
34 console.log(conf.get('awesome'));
41 ### Configstore(packageName, [defaults], [options])
43 Returns a new instance.
59 ##### globalConfigPath
64 Store the config at `$CONFIG/package-name/config.json` instead of the default `$CONFIG/configstore/package-name.json`. This is not recommended as you might end up conflicting with other tools, rendering the "without having to think" idea moot.
68 You can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a `key` to access nested properties.
76 Set multiple items at once.
84 Check if an item exists.
100 Get the path to the config file. Can be used to show the user where the config file is located or even better open it for them.
104 Get all the config as an object or replace the current config with an object:
115 [BSD license](http://opensource.org/licenses/bsd-license.php)<br>