Skip to main content

For AI Agents & LLMs

This page is a dense, single-screen map of strata-storage for AI coding agents (Claude Code, Cursor, Copilot, etc.). It exists so you can integrate the package into any project by matching the host project's needs to the right adapters and features — without reading the whole site.

Package: strata-storage · current version 2.8.2 · MIT · zero runtime dependencies. Install: npm i strata-storage (or yarn add strata-storage). Node ≥ 24.13.

Machine-readable companions: /llms.txt (index) and /llms-full.txt (the entire docs concatenated into one file for one-shot ingestion). A bundled AI-INTEGRATION-GUIDE.md also ships inside the npm package.

What it is

One unified async + sync key-value API over many backends — web (localStorage, IndexedDB, cookies, Cache API, memory, URL), native mobile via Capacitor (Preferences, Keychain/Keystore, SQLite, Filesystem), and optional remote (Firebase). Zero runtime dependencies; framework/native/Firebase deps are optional peer deps. Features (encryption, compression, TTL, queries, sync, integrity/recovery) are opt-in and compose across any backend.

Entry points (import map)

ImportProvides
strata-storageStrata, defineStorage, the default storage, all web adapters, URLAdapter, feature helpers.
strata-storage/capacitorPreferencesAdapter, SecureAdapter, SqliteAdapter, FilesystemAdapter.
strata-storage/firebaseenableFirebaseSync, isFirebaseAvailable.
strata-storage/reactcreateStrataHooks (provider-free) + <StrataProvider>.
strata-storage/vuecreateStrataComposables + StrataPlugin.
strata-storage/angularprovideStrata / StrataService (RxJS).

Adapters (pick by { storage: '...' })

storagePlatformSync API?ObservableQueryableUse when
memoryalltests, ephemeral cache
localStoragewebsmall persistent data
sessionStoragewebper-session data
indexedDBweblarge / structured data
cookieswebsmall server-readable data
cacheweboffline assets / big blobs
urlwebshareable UI state in the URL
preferencesCapacitorsimple native settings
secureCapacitorsecrets (Keychain/Keystore)
sqliteCapacitorstructured / multi-store (database+table)
filesystemCapacitordocument-shaped values
firestoreFirebasecross-device/user document sync
realtimeFirebaselow-latency shared state

Sync-API adapters support getSync/setSync/...; the rest are async-only. See the adapters reference.

defineStorage() auto-registers the web adapters except url — call storage.registerAdapter(new URLAdapter()) (imported from strata-storage) before using { storage: 'url' }. Native adapters need registerCapacitorAdapters(); firestore/realtime need enableFirebaseSync().

Features (opt-in, compose on any backend)

FeatureEnable with
Encryptionencryption: { enabled, password, algorithm } config, or per-op { encrypt: true, encryptionPassword }
Compression{ compress: true } (algorithm 'lz')
TTL / expiry{ ttl: ms }; getTTL/extendTTL/persist
Queryquery(condition) matches the stored value's own bare fields (MongoDB-style operators)
Tags{ tags: [...] } group values; filter with clear({ tags }) (tags are NOT queryable via query())
Cross-tab syncsync: { enabled: true, storages: ['localStorage'] }
Cross-device syncenableFirebaseSync(storage, config)
Integrity / recovery{ integrity, durableWrites, mirror, autoBackup }; snapshot()/restore()
Namespacingnamespace (config or per-op) isolates keys

Encryption (2.7.0): AES-GCM (default, AEAD) or AES-CBC (authenticated via Encrypt-then-MAC); PBKDF2 default 600,000 iterations. See the encryption API.

Framework bindings (provider-free)

// React
import { createStrataHooks } from 'strata-storage/react';
export const { useStorage } = createStrataHooks(defineStorage());

// Vue
import { createStrataComposables } from 'strata-storage/vue';
export const { useStorage } = createStrataComposables(defineStorage());

// Angular
import { provideStrata } from 'strata-storage/angular'; // providers: [provideStrata(defineStorage())]

Recipes

Web app, fast persistent store

import { defineStorage } from 'strata-storage';
export const storage = defineStorage({ defaultStorages: ['indexedDB', 'localStorage'] });
await storage.set('cart', items);

Secure value on mobile (Capacitor)

import { defineStorage } from 'strata-storage';
import { SecureAdapter } from 'strata-storage/capacitor';
const storage = defineStorage();
storage.registerAdapter(new SecureAdapter());
await storage.set('token', jwt, { storage: 'secure' });

Cross-device sync (Firebase)

import { enableFirebaseSync } from 'strata-storage/firebase';
await enableFirebaseSync(storage, { apiKey, authDomain, projectId, appId, firestore: true });
await storage.set('profile', data, { storage: 'firestore' });

Encrypted + expiring secret

await storage.set('otp', code, { encrypt: true, encryptionPassword: pw, ttl: 300_000 });

Query stored values (condition matches the stored value's own bare fields)

const rows = await storage.query({ status: 'active', score: { $gte: 10 } });
// => Array<{ key: string; value: T }>

Package & contact

Caveats for agents: browser encryption needs a secure context (HTTPS/localhost) for crypto.subtle; getSync/setSync throw on async-only adapters and on encrypted/compressed values — use the async API there.

Most-used API

get<T> · set<T> · remove · has · keys · clear · query<T> · subscribe · getSync/setSync/… · snapshot/restore · getTTL/extendTTL/persist · cleanupExpired · registerAdapter. Full signatures: Core API.

See also