# @k8slens/electron-sync-store

> Electron Sync Store

Latest version **0.5.3** (published 2025-04-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @k8slens/electron-sync-store
pnpm add @k8slens/electron-sync-store
yarn add @k8slens/electron-sync-store
bun add @k8slens/electron-sync-store
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.3 |
| Published | 2025-04-24 |
| First published | 2022-03-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^22.14.0 |
| Dependencies | 3 |
| Unpacked size | 67.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Mirantis Inc |
| Maintainers | jakolehm, k8slens-bot, mirantis_it |

## Links

- npm: https://www.npmjs.com/package/@k8slens/electron-sync-store
- Repository: https://github.com/lensapp/electron-sync-store
- Homepage: https://github.com/lensapp/electron-sync-store#readme
- Issues: https://github.com/lensapp/electron-sync-store/issues
- npm.io page: https://npm.io/package/@k8slens/electron-sync-store

## Dependencies (3)

- [atomically](https://npm.io/package/atomically.md) 1.7.0
- [exponential-backoff](https://npm.io/package/exponential-backoff.md) 3.1.1
- [@ogre-tools/linkable](https://npm.io/package/@ogre-tools/linkable.md) 17.0.0

## Recent versions

- 0.5.3 (latest) — 2025-04-24
- 0.5.2 — 2024-09-26
- 0.5.1 — 2024-07-04
- 0.5.0 — 2023-07-17
- 0.4.3 — 2023-07-17
- 0.4.2 — 2023-06-27
- 0.4.1 — 2023-05-31
- 0.4.0 — 2023-05-25
- 0.3.9 — 2023-05-24
- 0.3.8 — 2023-05-15
- 0.3.7 — 2023-05-09
- 0.3.6 — 2022-12-08
- 0.3.5 — 2022-12-08
- 0.3.4 — 2022-12-07
- 0.3.3 — 2022-12-07
- … 10 more at https://npm.io/package/@k8slens/electron-sync-store/versions

## README

# electron-sync-store

Store and load JSON-serialized data to a file in electron. Supports both main and renderer. Files are written atomically.

Inspired by `conf`, `electron-store` and `BaseStore` of OpenLens.

Benefits:
* async operations
* increased performance

In race condition of multiple writes the saved file is arbitrary.

Usage:

```ts
import { ElectronSyncStore, modelUpdateEventName } from "electron-sync-store";

// Note: 'store-name' must be unique
const store = ElectronSyncStore.initialize<Model>("store-name", defaultModel, "store.json",  /* options */);

// Listen to model changes
store.events.on(modelUpdateEventName, model => {
  //
});

// After you're done with the store:
store.dispose();
```

### Architecture

* Main and renderer instances load initial mode from file
* Main instances save model updates to the file and broadcast the update to renderer and other main instances
* Renderer will broadcast model updates to main, which will save the change and broadcast the update again

## License

Copyright (c) 2022 Mirantis, Inc.

Licensed under the MIT license.
<https://opensource.org/licenses/MIT>

---
_Source: https://npm.io/package/@k8slens/electron-sync-store · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
