desktop-storage-electron
Electron Storage & Credentials
Quick Guide: Use
electron-storefor typed JSON preferences (small key-value config with schema validation, migrations, and file watching). Usebetter-sqlite3for structured/relational data or anything beyond simple key-value (synchronous, WAL mode, transactions). UsesafeStoragefor encrypting secrets like tokens and API keys via the OS keychain -- it replaces the deprecatedkeytar. All persistent data belongs underapp.getPath("userData"). Never store secrets in plain JSON files.
<critical_requirements>
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST use safeStorage.encryptString() / safeStorage.decryptString() for secrets -- never store tokens, API keys, or passwords in plain text or in electron-store without OS-level encryption)
(You MUST store all persistent data under app.getPath("userData") -- never write to the app installation directory, which is replaced on updates)
(You MUST enable WAL mode (PRAGMA journal_mode = WAL) when using better-sqlite3 -- it prevents readers from blocking writers and avoids SQLITE_BUSY errors in multi-window apps)
(You MUST call safeStorage.isEncryptionAvailable() before encrypting -- it returns false before the app ready event and on some Linux configurations)