AI agents: fetch the documentation index at llms.txt. Markdown versions are available by appending .md to any page URL, including this page's markdown.
@stratasync/storage-idb
IndexedDB storage adapter for offline-first client-side persistence in Strata Sync.
Implements StorageAdapter using IndexedDB. Persists model data, the outbox, sync metadata, partial indexes, and sync actions for offline-first operation and instant startup.
What it provides
createIndexedDbStorage: factory function that creates a configured StorageAdapter instance
IndexedDbStorageAdapter: the class implementing the full StorageAdapter interface
DatabaseManager: manages a registry of workspace databases for multi-user/multi-version support
Store operations: typed functions for model rows, metadata, outbox transactions, partial indexes, and sync actions
Schema migrations: automatic IndexedDB schema upgrades when the model schema changes
Store name utilities: deterministic hashing for store and database names
Installation
npm install @stratasync/storage-idb
@stratasync/storage-idb has no peer dependencies. It uses the idb library (^8.0.0) internally for a promise-based IndexedDB wrapper.
interface StorageOptions { /** Database name override (auto-generated if omitted) */ name?: string; /** Client version used to derive the workspace database name */ version?: number; /** Logged-in user ID (used to derive the workspace database name) */ userId?: string; /** Per-user version used to derive the workspace database name */ userVersion?: number; /** Schema definition or registry snapshot */ schema?: SchemaDefinition | ModelRegistrySnapshot;}
When you don't provide name, the adapter computes the database name deterministically from userId, version, and userVersion using a hash function (for example, ss_<hash>).
Expand to see the internal IndexedDB database layout
The adapter manages multiple IndexedDB databases.
Workspace database
The main database contains these object stores:
Store
Key
Description
_meta
string
Sync metadata and per-model persistence flags.
_transaction
clientTxId
Outbox of pending transactions. Indexes: byState, byCreatedAt, byBatchIndex.
_sync_action
id
Persisted sync actions for debugging.
<model_hash>
Model primary key
One store per registered model. Store names are deterministic hashes.
Partial databases
For models with "partial" load strategy, a separate database stores partial index entries:
Store
Key
Description
partial_index
Composite key
Tracks which index key/value pairs have been fetched.
Database registry
A top-level stratasync_databases database tracks all workspace databases:
Store
Key
Description
databases
name
Maps database names to DatabaseInfo (userId, version, schemaHash, and more).
Schema migrations
When the schema changes (via computeSchemaHash), the adapter increments the IndexedDB version, creates new object stores, adds indexes for @Property({ indexed: true }) fields, and preserves unchanged stores. This happens transparently during open().
Multi-workspace support
Deterministic database naming supports multiple users and versions.