Registry / database / keyvaluestorage-interface

keyvaluestorage-interface

JSON →
library1.0.0jsnpmunverified

Isomorphic Key-Value Storage Interface (v1.0.0) providing a unified API across Node.js, React Native, and browser environments. Abstracts over AsyncStorage (React Native) and SQLite (Node.js) for persistent key-value storage. Ships TypeScript definitions and uses async/await. Lightweight (~1kB) with no runtime dependencies. Differentiator: single interface for multiple platforms without additional setup.

npm install keyvaluestorage-interface
INSTALL
IMPORT
SIG · KEYVALUESTORAGE-IN
K
keyvaluestorage-interface
databasejavascriptv1.0.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.

KeyValueStorage
import KeyValueStorage from 'keyvaluestorage-interface'
import { KeyValueStorage } from 'keyvaluestorage-interface'
Default export only, not named.
IKeyValueStorage
import { IKeyValueStorage } from 'keyvaluestorage-interface'
import IKeyValueStorage from 'keyvaluestorage-interface'
Type-only export for implementing your own storage adapter.

Basic usage: create storage instance (Node.js in-memory SQLite), set, get, list keys, and remove items.

import KeyValueStorage from 'keyvaluestorage-interface'; const options = { // For Node.js: SQLite database file path database: ':memory:', }; async function main() { const storage = new KeyValueStorage(options); await storage.setItem('user1', { name: 'John Doe', age: 21 }); const item = await storage.getItem('user1'); console.log(item); // { name: 'John Doe', age: 21 } const keys = await storage.getKeys(); console.log(keys); // ['user1'] await storage.removeItem('user1'); } main().catch(console.error);
Debug
Known issues
gotchaFor React Native, you must pass `asyncStorage` option from @react-native-async-storage/async-storage. The package does not auto-detect the platform.
fix
Install @react-native-async-storage/async-storage and pass it as `asyncStorage` option.
affects: >=1.0.0
gotchaFor Node.js, the `database` option is required. Supported values: file path string or `:memory:` for an in-memory SQLite database.
fix
Provide a valid database string (e.g., 'mydb.db') or ':memory:'.
affects: >=1.0.0
gotchaThe `tableName` option defaults to `'keyvaluestorage-interface'`. If you change it, you must be consistent across all operations on the same database.
fix
 Use the same tableName for all storage operations against the same database file.
affects: >=1.0.0
gotchaThe library does not support browser localStorage directly; use the Node.js adapter with a WebSQL polyfill or wait for browser support.
fix
Consider using 'localforage' or similar for browser-only apps.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: KeyValueStorage is not a constructor
Using named import instead of default import.
fix
Change to `import KeyValueStorage from 'keyvaluestorage-interface'`
NoSQLiteError: SQLITE_CANTOPEN: unable to open database file
Missing `database` option for Node.js platform.
fix
Provide a database path or ':memory:' in options object.
Error: AsyncStorage must be provided for React Native
React Native usage without passing `asyncStorage` option.
fix
Pass the AsyncStorage module from @react-native-async-storage/async-storage.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
Amazon
1
Resources
keyvaluestorage-interface — npm install keyvaluestorage-interface · libregistry