Easily load and persist config without having to think about where and how

License: BSD-2-Clause

Language: JavaScript

configstore Build Status

Easily load and persist config without having to think about where and how

The config is stored in a JSON file located in $XDG_CONFIG_HOME or ~/.config.
Example: ~/.config/configstore/some-id.json

If you need this for Electron, check out electron-store instead.
And check out conf for an updated approach to this concept.


$ npm install configstore


const Configstore = require('configstore');
const packageJson = require('./package.json');

// Create a Configstore instance
const config = new Configstore(, {foo: 'bar'});

//=> 'bar'

config.set('awesome', true);
//=> true

// Use dot-notation to access nested properties
config.set('bar.baz', true);
//=> {baz: true}

//=> undefined


Configstore(packageName, defaults?, options?)

Returns a new instance.


Type: string

Name of your package.


Type: object

Default config.


Type: object


Type: boolean
Default: false

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.


Type: string
Default: Automatic

Please don't use this option unless absolutely necessary and you know what you're doing.

Set the path of the config file. Overrides the packageName and globalConfigPath options.


You can use dot-notation in a key to access nested properties.

.set(key, value)

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 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.


Get all the config as an object or replace the current config with an object:

config.all = {
	hello: 'world'

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Project Statistics

Sourcerank 18
Repository Size 75.2 KB
Stars 601
Forks 50
Watchers 19
Open issues 1
Dependencies 8
Contributors 21
Tags 31
Last updated
Last pushed

Top Contributors See all

Sindre Sorhus Simon Boudrias Pascal Hartig André Cruz Mat Scales Bret Comnes Addy Osmani Krishnan Anantheswaran noffle Eran Tiktin Moritz Kröger Max Hallinan Jason Dent wtgtybhertgeghgtwtg Irmantas Kevin Mårtensson Zeno Rocha Kyle E. Mitchell Siddharth Kannan

Packages Referencing this Repo

Easily load and save config without having to think about where and how
Latest release 5.0.1 - Updated - 601 stars

Recent Tags See all

v5.0.1 February 13, 2020
v5.0.0 June 11, 2019
v4.0.0 July 28, 2018
v3.1.2 March 26, 2018
v3.1.1 July 20, 2017
v3.1.0 May 10, 2017
v3.0.0 February 13, 2017
2.1.0 February 11, 2017
v2.1.0 September 01, 2016
v2.0.0 March 01, 2016
v1.4.0 December 09, 2015
v1.3.0 October 27, 2015
v1.2.1 August 04, 2015
1.2.0 June 30, 2015
1.1.0 June 09, 2015

Interesting Forks See all

Easily load and persist config without having to think about where and how
JavaScript - Updated - 2 stars

Something wrong with this page? Make a suggestion

Last synced: 2020-02-13 17:45:50 UTC

Login to resync this repository