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.
Persister | Storage | Store | MergeableStore |
---|---|---|---|
SessionPersister | Browser session storage | Yes | Yes |
LocalPersister | Browser local storage | Yes | Yes |
FilePersister | Local file (where possible) | Yes | Yes |
IndexedDbPersister | Browser IndexedDB | Yes | No |
RemotePersister | Remote server | Yes | No |
Sqlite3Persister | SQLite in Node, via sqlite3 | Yes | Yes* |
SqliteWasmPersister | SQLite in a browser, via sqlite-wasm | Yes | Yes* |
ExpoSqlitePersister | SQLite in React Native, via expo-sqlite | Yes | Yes* |
PostgresPersister | PostgreSQL, via postgres | Yes | Yes* |
PglitePersister | PostgreSQL, via PGlite | Yes | Yes* |
CrSqliteWasmPersister | SQLite CRDTs, via cr-sqlite-wasm | Yes | No |
ElectricSqlPersister | Electric SQL, via electric-sql | Yes | No |
LibSqlPersister | LibSQL for Turso, via libsql-client | Yes | No |
PowerSyncPersister | PowerSync, via powersync-sdk | Yes | No |
YjsPersister | Yjs CRDTs, via yjs | Yes | No |
AutomergePersister | Automerge CRDTs, via automerge-repo | Yes | No |
PartyKitPersister | PartyKit, via the persister-partykit-server module | Yes | No |
(*) 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
- Persistence guides
- Countries demo
- Todo App demos
- Drawing demo
Since
v1.0.0