1 | # Electron Settings
|
2 |
|
3 | A simple and robust settings management library for [Electron](https://electronjs.org).
|
4 |
|
5 | Born from Atom's original internal configuration manager and the settings manager of choice for Electron's own [API Demos app](https://github.com/electron/electron-api-demos), Electron Settings allows you to persist user settings and other data between app loads simply and easily.
|
6 |
|
7 | [![Npm version][badge_npm-version]][external_npm]
|
8 | [![Npm downloads][badge_npm-downloads]][external_npm]
|
9 | [![David][badge_david]][external_david]
|
10 | [![Travis][badge_travis]][external_travis]
|
11 |
|
12 | <br/>
|
13 |
|
14 | ### Install
|
15 |
|
16 | ```
|
17 | npm install electron-settings
|
18 | ```
|
19 |
|
20 | ### Demo
|
21 |
|
22 | ```ts
|
23 | import settings from 'electron-settings';
|
24 |
|
25 | await settings.set('color', {
|
26 | name: 'cerulean',
|
27 | code: {
|
28 | rgb: [0, 179, 230],
|
29 | hex: '#003BE6'
|
30 | }
|
31 | });
|
32 |
|
33 | await settings.get('color.name');
|
34 | // => "cerulean"
|
35 |
|
36 | await settings.get('color.code.rgb[1]');
|
37 | // => 179
|
38 | ```
|
39 |
|
40 | ⚠ For Electron v10+, if you want to use electron-settings within a browser window, be sure to set the `enableRemoteModule` web preference to `true`. Otherwise you might get the error `Cannot read property 'app' of undefined`. See [#133](https://github.com/nathanbuchar/electron-settings/issues/133) for more info.
|
41 |
|
42 | ```js
|
43 | new BrowserWindow({
|
44 | webPreferences: {
|
45 | enableRemoteModule: true // <-- Add me
|
46 | }
|
47 | });
|
48 | ```
|
49 |
|
50 | ### API Docs
|
51 |
|
52 | API docs and can be found at [electron-settings.js.org](https://electron-settings.js.org).
|
53 |
|
54 |
|
55 |
|
56 | <br/>
|
57 | <br/>
|
58 | <hr/>
|
59 |
|
60 | <small>**Having trouble?** [Get help on Gitter][external_gitter].</small>
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | [docs]: https://nathanbuchar.github.io/electron-settings/
|
67 |
|
68 | [badge_npm-version]: https://img.shields.io/npm/v/electron-settings.svg
|
69 | [badge_npm-downloads]: https://img.shields.io/npm/dm/electron-settings.svg
|
70 | [badge_david]: https://img.shields.io/david/nathanbuchar/electron-settings.svg
|
71 | [badge_travis]: https://img.shields.io/travis/nathanbuchar/electron-settings/master.svg
|
72 |
|
73 | [external_david]: https://david-dm.org/nathanbuchar/electron-settings
|
74 | [external_electron]: https://electron.atom.io
|
75 | [external_gitter]: https://gitter.im/nathanbuchar/electron-settings
|
76 | [external_npm]: https://npmjs.org/package/electron-settings
|
77 | [external_travis]: https://travis-ci.org/nathanbuchar/electron-settings.svg?branch=master
|