{"id":44826,"library":"electron-store","title":"electron-store","description":"Simple data persistence for Electron apps and modules, saving and loading user settings, app state, and cache as a JSON file in the user data directory. v11.0.2 is the current stable release, requiring Electron 30+ and Node.js 20+. The package is native ESM only (no CommonJS). Key differentiators: JSON Schema validation via ajv, atomic disk writes, dot-notation access for nested properties, migration support for version upgrades. Actively maintained by Sindre Sorhus.","status":"active","version":"11.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/sindresorhus/electron-store","tags":["javascript","electron","store","app","config","storage","conf","configuration","settings","typescript"],"install":[{"cmd":"npm install electron-store","lang":"bash","label":"npm"},{"cmd":"yarn add electron-store","lang":"bash","label":"yarn"},{"cmd":"pnpm add electron-store","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for JSON Schema validation when schema option is provided.","package":"ajv","optional":true},{"reason":"Underlying configuration store library used for core functionality.","package":"conf","optional":false},{"reason":"Ensures atomic writes to disk to prevent corruption.","package":"atomically","optional":false}],"imports":[{"note":"Default export. Package is ESM-only since v9; CommonJS require will fail.","wrong":"const Store = require('electron-store')","symbol":"Store","correct":"import Store from 'electron-store'"},{"note":"Named import does not work; uses default export.","wrong":"import { Store } from 'electron-store'","symbol":"Store","correct":"import Store from 'electron-store'"},{"note":"For TypeScript, you can use type-only import to avoid runtime value.","wrong":"import Store from 'electron-store' (not needed for types)","symbol":"electron-store (type)","correct":"import type Store from 'electron-store'"}],"quickstart":{"code":"import Store from 'electron-store';\n\nconst store = new Store({\n  defaults: {\n    unicorn: '🦄',\n    foo: { bar: true }\n  },\n  schema: {\n    unicorn: {\n      type: 'string'\n    },\n    'foo.bar': {\n      type: 'boolean'\n    }\n  }\n});\n\nstore.set('unicorn', '🦄');\nconsole.log(store.get('unicorn'));\n//=> '🦄'\n\nstore.set('foo.bar', true);\nconsole.log(store.get('foo'));\n//=> { bar: true }\n\nstore.delete('unicorn');\nconsole.log(store.get('unicorn'));\n//=> undefined\n\nstore.clear();\nconsole.log(store.size);\n//=> 0","lang":"typescript","description":"Creates a store with defaults and schema validation, then demonstrates set, get, delete, and clear operations."},"warnings":[{"fix":"Convert your project to ESM (use 'import' instead of 'require'). More info: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c","message":"electron-store v9+ is ESM-only and no longer provides a CommonJS export. Using require() throws an error.","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Update Node.js to >=20 and Electron to >=30.","message":"electron-store v11 drops support for Node.js <20 and Electron <30.","severity":"breaking","affected_versions":">=11.0.0"},{"fix":"Consider implementing custom migration logic outside the library.","message":"The `migrations` feature is known to have bugs and is not actively maintained. Use with caution.","severity":"gotcha","affected_versions":"*"},{"fix":"Access store after app 'ready' event or in the main process only if using in renderer.","message":"Data is saved as config.json in app.getPath('userData'). Ensure the app is ready before accessing the store.","severity":"gotcha","affected_versions":"*"},{"fix":"Remove `beforeEachMigration` and include logic inside migration handlers.","message":"The `beforeEachMigration` option has been deprecated. Use migration functions directly.","severity":"deprecated","affected_versions":">=10.0.0"}],"env_vars":null,"search_vec":"'20':41 '30':38 'access':63 'activ':72 'ajv':56 'app':9,17,80 'atom':57 'cach':20 'commonj':49 'conf':83 'config':81 'configur':84 'current':33 'data':5,28 'differenti':51 'directori':29 'disk':58 'dot':61 'dot-not':60 'electron':2,8,37,78 'electron-stor':1 'esm':46 'file':24 'javascript':77 'json':23,52 'key':50 'load':14 'maintain':73 'migrat':67 'modul':11 'nativ':45 'nest':65 'node.js':40 'notat':62 'packag':43 'persist':6 'properti':66 'releas':35 'requir':36 'save':12 'schema':53 'set':16,85 'simpl':4 'sindr':75 'sorhus':76 'stabl':34 'state':18 'storag':82 'store':3,79 'support':68 'typescript':86 'upgrad':71 'user':15,27 'v11.0.2':30 'valid':54 'version':70 'via':55 'write':59","created_at":"2026-06-07T12:52:01.761323+00:00","updated_at":"2026-06-07T12:52:01.761323+00:00","problems":[{"fix":"Switch to ESM by setting 'type': 'module' in package.json and using import syntax.","cause":"Project uses CommonJS (require) but electron-store is ESM-only since v9.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Ensure the value passed to store.set() conforms to the schema type and constraints.","cause":"Trying to set a value that doesn't match the JSON schema defined in options.","error":"Error: Config schema violation: 'foo' should be number"},{"fix":"Use 'import Store from 'electron-store'' (default import).","cause":"Using a named import { Store } instead of default import.","error":"TypeError: store.set is not a function"},{"fix":"Set 'type': 'module' in package.json or rename file to .mjs.","cause":"CommonJS require in a Node.js environment that doesn't support ESM interop.","error":"Error: The 'electron-store' package is not compatible with CommonJS"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/sindresorhus/electron-store#readme","github":"https://github.com/sindresorhus/electron-store","docs":null,"changelog":null,"pypi":null,"npm":"electron-store","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}