TinyBase logoTinyBase

persisters

The persisters module of the TinyBase project provides a simple framework for saving and loading Store and MergeableStore data, to and from different destinations, or underlying storage types.

Many entry points are provided (in separately installed modules), each of which returns different types of Persister that can load and save a Store. Between them, these allow you to store your TinyBase data locally, remotely, to SQLite and PostgreSQL databases, and across synchronization boundaries with CRDT frameworks.

PersisterStorageStoreMergeableStore
SessionPersisterBrowser session storageYesYes
LocalPersisterBrowser local storageYesYes
FilePersisterLocal file (where possible)YesYes
IndexedDbPersisterBrowser IndexedDBYesNo
RemotePersisterRemote serverYesNo
Sqlite3PersisterSQLite in Node, via sqlite3YesYes*
SqliteWasmPersisterSQLite in a browser, via sqlite-wasmYesYes*
ExpoSqlitePersisterSQLite in React Native, via expo-sqliteYesYes*
PostgresPersisterPostgreSQL, via postgresYesYes*
PglitePersisterPostgreSQL, via PGliteYesYes*
CrSqliteWasmPersisterSQLite CRDTs, via cr-sqlite-wasmYesNo
ElectricSqlPersisterElectric SQL, via electric-sqlYesNo
LibSqlPersisterLibSQL for Turso, via libsql-clientYesNo
PowerSyncPersisterPowerSync, via powersync-sdkYesNo
YjsPersisterYjs CRDTs, via yjsYesNo
AutomergePersisterAutomerge CRDTs, via automerge-repoYesNo
PartyKitPersisterPartyKit, via the persister-partykit-server moduleYesNo

(*) Note that SQLite- and PostgreSQL-based Persisters can currently only persist MergeableStore data when used with the JSON-based DpcJson mode, and not when using the DpcTabular mode.

Since persistence requirements can be different for every app, the createCustomPersister function in this module can also be used to easily create a fully customized way to save and load Store data.

Similarly, the createCustomSqlitePersister function and createCustomPostgreSqlPersister function can be used to build Persister objects against SQLite and PostgreSQL SDKs (or forks) that are not already included with TinyBase.

See also

Since

v1.0.0

Interfaces

Enumerations

Functions

Type Aliases