Registry / security / keychain-synced-storage

keychain-synced-storage

JSON →
library0.9.0jsnpmunverified

A secure, encrypted, Keychain/Keystore-backed storage adapter for Expo and React Native (version 0.9.0). It maintains an in-memory Map for synchronous reads/writes while automatically encrypting data with a device-keychain-protected key and persisting the encrypted blob to AsyncStorage asynchronously. Supports isolated custom data namespaces for sensitive app data, biometric/passcode protection, and transparent integration with existing storage APIs. Alternative to react-native-encrypted-storage and expo-secure-store with a focus on session persistence and minimal API overhead. Active development; release cadence is irregular.

npm install keychain-synced-storage
INSTALL
IMPORT
SIG · KEYCHAIN-SYNCED-ST
K
keychain-synced-storage
securityjavascriptv0.9.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createKeychainSyncedStorage
import { createKeychainSyncedStorage } from 'keychain-synced-storage'
import createKeychainSyncedStorage from 'keychain-synced-storage'
Library only exports named function, not default.
KeychainSyncedStore
const { store: KeychainSyncedStore } = createKeychainSyncedStorage(config)
import { KeychainSyncedStore } from 'keychain-synced-storage'
The store is destructured from the factory return, not imported directly.
load
const { load: initializeAuth } = createKeychainSyncedStorage(config)
import { load } from 'keychain-synced-storage'
Must destructure from factory call; rename to avoid conflicts.

Demonstrates init, load, sync/async set/get, custom namespace, removal, and flush of keychain-synced-storage.

import { createKeychainSyncedStorage } from 'keychain-synced-storage'; import AsyncStorage from '@react-native-async-storage/async-storage'; // Initialize storage const storage = createKeychainSyncedStorage({ storagePrefixKey: 'com.myapp.auth' }); // Register custom namespace (optional) const privateKeyStore = storage.registerCustomData({ service: 'private-key', version: 1 }); const { store: KeychainSyncedStore, load } = storage; // Initialize async (must complete before use) await load(); // Write and read synchronously KeychainSyncedStore.setItem('session', JSON.stringify({ token: 'abc' })); const session = KeychainSyncedStore.getItem('session'); console.log(session); // '{"token":"abc"}' // Async write (waits for encryption sync) await KeychainSyncedStore.setItemAsync('refreshToken', 'xyz'); // Custom namespace usage privateKeyStore.setItem('privateKey', '0x123...'); // Remove item KeychainSyncedStore.removeItem('session'); // Force flush pending syncs await KeychainSyncedStore.flush?.();
Debug
Known issues
breakingVersion 0.x has no stable API; breaking changes may occur without major version bump.
fix
Pin version or expect to update imports on upgrade.
affects: <1.0.0
deprecatedregisterCustomData() must be called before load(); otherwise it will throw.
fix
Always call registerCustomData before load in initialization sequence.
affects: >=0.9.0
gotchasetItemAsync() returns a promise that resolves after background encryption sync completes; relying on setItem() will not wait for persist.
fix
Use setItemAsync() when you need to guarantee data is persisted before next launch.
affects: >=0.9.0
gotchaflush() method may not exist in older versions; check before calling.
fix
Upgrade to 0.9.0 or use setItemAsync() to force sync.
affects: <0.9.0
breakingIn-memory Map is cleared on app restart; must call load() before any getItem reads.
fix
Call load() in initializer before accessing store.
affects: >=0.9.0
Errors
Common errors & fixes
TypeError: Cannot destructure property 'store' of 'createKeychainSyncedStorage(...)' as it is undefined.
Factory returned undefined due to missing peer dependency.
fix
Ensure all peer dependencies are installed: npm install @react-native-async-storage/async-storage react-native-keychain react-native-aes-crypto
Error: registerCustomData must be called before load
registerCustomData called after load() or not at all.
fix
Call registerCustomData immediately after createKeychainSyncedStorage, before load().
Attempt to getItem before storage is initialized
getItem called before load() completes.
fix
Guard storage access behind a state flag set after load resolves.
Module "keychain-synced-storage" does not exist in the Haste module map
Metro cannot resolve the package; may be incorrectly linked.
fix
Clear Metro cache: npx react-native start --reset-cache
Upgrade
Version history
0.9.0latest on npm
Audit
Dependencies
@react-native-async-storage/async-storagerequiredPersistence layer for encrypted blob
react-nativerequiredRequired for native modules (keychain, AES)
react-native-aes-cryptorequiredAES encryption/decryption of session data
react-native-keychainrequiredSecure storage of encryption key in device keychain/keystore
Agent activity
18 hits · last 30 days
node
18
Resources
keychain-synced-storage — npm install keychain-synced-storage · libregistry