Socket
Socket
Sign inDemoInstall

electron-store

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-store

Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc


Version published
Weekly downloads
118K
decreased by-4%
Maintainers
1
Weekly downloads
 
Created

What is electron-store?

The electron-store npm package is a simple and efficient way to manage persistent user data in Electron applications. It provides a straightforward API for reading and writing JSON data, making it easy to store settings, preferences, and other types of data.

What are electron-store's main functionalities?

Basic Usage

This feature allows you to set, get, and delete key-value pairs in the store. It's useful for storing simple settings or preferences.

const Store = require('electron-store');
const store = new Store();

// Set a value
store.set('unicorn', '🦄');

// Get a value
console.log(store.get('unicorn'));
//=> '🦄'

// Delete a value
store.delete('unicorn');

Default Values

You can define default values for your store. These values will be used if no other value is set for the given key.

const Store = require('electron-store');
const store = new Store({
  defaults: {
    foo: 'bar'
  }
});

console.log(store.get('foo'));
//=> 'bar'

Schema Validation

You can define a schema to validate the data being stored. This ensures that the data conforms to the expected format and constraints.

const Store = require('electron-store');
const store = new Store({
  schema: {
    foo: {
      type: 'string',
      maxLength: 10,
      default: 'bar'
    }
  }
});

store.set('foo', 'baz');
console.log(store.get('foo'));
//=> 'baz'

Encryption

You can encrypt the data stored in the store by providing an encryption key. This adds a layer of security to sensitive data.

const Store = require('electron-store');
const store = new Store({
  encryptionKey: 'mySecretEncryptionKey'
});

store.set('unicorn', '🦄');
console.log(store.get('unicorn'));
//=> '🦄'

Other packages similar to electron-store

Keywords

FAQs

Package last updated on 01 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc