Registry / storage / strata-storage

strata-storage

JSON →
library2.6.1jsnpmunverified

Strata Storage v2.6.1 is a zero-dependency universal storage library providing a unified API for web, Android, and iOS platforms. It supports multiple backends: localStorage, IndexedDB, sessionStorage, cookies, URL, and native Keychain/Keystore via Capacitor, with optional adapters for React, Vue, Angular, and Firebase. The core is pure TypeScript with strict types, ESM-only, requires Node >=24.13.0. Differentiators: provider-free usage (no React context or Vue plugin needed), opt-in encryption/compression/TTL/cross-tab sync, and zero runtime dependencies. Release cadence is active with minor updates.

npm install strata-storage
INSTALL
IMPORT
SIG · STRATA-STORAGE
S
strata-storage
storagejavascriptv2.6.1
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.

storage
import { storage } from 'strata-storage'
import storage from 'strata-storage'
Named export for pre-configured default instance. No default export.
defineStorage
import { defineStorage } from 'strata-storage'
const { defineStorage } = require('strata-storage')
ESM-only; require() not supported. Factory creates custom storage instances.
StrataStorage
import { StrataStorage } from 'strata-storage'
import { StrataStorage } from 'strata-storage/core'
TypeScript type for storage instances. Not available in CJS; import from main entry.
StorageOptions
import type { StorageOptions } from 'strata-storage'
import { StorageOptions } from 'strata-storage'
Type-only import recommended for definition files. Not a runtime value.

Shows basic get/set/remove/clear operations with default 'storage' instance, then creating a custom encrypted instance with defineStorage().

import { storage } from 'strata-storage'; // No setup, no Provider, no initialize() call — works immediately. await storage.set('user', { id: 123, name: 'John Doe' }); const user = await storage.get('user'); await storage.remove('user'); await storage.clear(); // Custom instance with encryption import { defineStorage } from 'strata-storage'; const myStorage = defineStorage({ defaultStorages: ['indexedDB', 'localStorage'], encryption: { enabled: true, password: process.env.STORAGE_KEY ?? 'fallback-secret' }, }); await myStorage.set('secret', 'sensitive', { encrypt: true }); const secret = await myStorage.get('secret', { decrypt: true });
Debug
Known issues
breakingVersion 2.0 dropped CommonJS support; ESM-only.
fix
Switch to ES modules: use import instead of require(), ensure package.json contains 'type': 'module'.
affects: >=2.0.0
breakingVersion 2.0 removed Provider/Plugin/Module patterns in favor of provider-free architecture. Old React Context API no longer works.
fix
Use defineStorage() to create a shared instance and pass it via props or module import. See migration guide.
affects: >=2.0.0
deprecatedstorage.initialize() is deprecated; instances initialize lazily on first call.
fix
Remove all initialize() calls. Just call set/get/remove directly.
affects: >=2.0.0
gotchaEncryption requires a password or key; if not provided, set() with encrypt: true throws.
fix
Always configure encryption.password in defineStorage options or pass password per-call.
affects: >=2.6.0
gotchaCross-tab sync requires IndexedDB adapter; localStorage does not support sync.
fix
Ensure 'indexedDB' is in defaultStorages when subscribing to cross-tab updates.
affects: all
Errors
Common errors & fixes
Cannot find module 'strata-storage' or its corresponding type declarations.
Missing TypeScript types or misconfigured tsconfig.json (e.g., moduleResolution not set to 'node16' or 'bundler').
fix
Set 'moduleResolution': 'bundler' (or 'node16') and 'module': 'esnext' in tsconfig.json. Ensure 'skipLibCheck': false temporarily to verify types.
ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/strata-storage/dist/index.js from ... not supported.
Using CommonJS require() with an ESM-only package.
fix
Use dynamic import() instead of require(), or convert project to ES modules by adding 'type': 'module' to package.json.
TypeError: storage.set is not a function
Attempting to call set() before the storage instance is fully initialized, or using a wrong import (e.g., default import instead of named).
fix
Ensure you do: import { storage } from 'strata-storage'. Then use await storage.set().
EncryptionError: No encryption key configured
Calling set() with encrypt: true but no encryption password set in defineStorage options.
fix
In defineStorage(), add encryption: { enabled: true, password: 'your-secret' } or pass password per-call: set(key, value, { encrypt: true, password: '...' })
Upgrade
Version history
2.6.1latest on npm
Audit
Dependencies
@angular/coreoptionalRequired for Angular adapter (strata-storage/angular)
@angular/formsoptionalRequired for Angular adapter (strata-storage/angular)
@capacitor/coreoptionalRequired for native iOS/Android adapters via Capacitor
reactoptionalRequired for React adapter (strata-storage/react)
vueoptionalRequired for Vue adapter (strata-storage/vue)
Agent activity
23 hits · last 30 days
node
20
Amazon
1
Resources
strata-storage — npm install strata-storage · libregistry