Skip to main content
Version: 0.7

Storage

Every Credo agent needs a storage module to keep its state between restarts: DIDs, credentials, OpenID4VC issuers and sessions, DIDComm connections, tenants and generic records. Credo ships two, Drizzle and Askar, and one of them stores the records. Without one, new Agent() throws Missing required dependency: 'StorageService'.

Which should I use?​

You're buildingRecordsKeys
A serverDrizzle on PostgreSQLAskar, with storage turned off
A server with one instance, or local developmentDrizzle on SQLiteAskar, with storage turned off
A mobile walletAskar on SQLiteAskar
TestsDrizzle on in-memory SQLiteNode.js backend, in memory. Askar in memory for DIDComm, which needs algorithms only Askar has

Drizzle scales better on servers: records are SQL tables with indexes that the database can query, and many tenants and instances share one database.

On phones, Askar encrypts the wallet with a key you keep in the device keychain, includes key management, and has no schema migrations to ship with app updates. Drizzle on expo-sqlite is an option there too.

Drizzle doesn't encrypt records, so rely on encryption of the database or disk. It also adds SQL migrations, also in non-breaking Credo releases, and Credo doesn't work until you apply them. If you can't run migrations on every deploy, use Askar on PostgreSQL for the records as well: it has no schema and encrypts everything with the store key. For many tenants on Askar, use a profile per tenant.

Askar and Drizzle compared​

AskarDrizzle
Package@credo-ts/askar@credo-ts/drizzle-storage
Encryption at restRecord values and tags are encrypted with the store keyNone. Use encryption of the database or disk
Key management includedYesNo, add a backend such as Askar
DatabasesSQLite, PostgreSQLPostgreSQL (pg driver), SQLite (libsql or expo-sqlite driver)
PlatformsNode.js, React NativeNode.js, React Native (with expo-sqlite)
Schema and migrationsNo schema, nothing to migrateSQL tables. Run migrations on every Credo upgrade
Multi-tenancyA database or a profile per tenantOne database, rows scoped per tenant
Read records outside CredoNo, the data is encryptedYes, a table per record type
Cursor pagination in queriesNo, only limit and offsetYes

Keys aren't records: the key management backend stores them. With Drizzle, Askar usually keeps the keys in a store of its own.

Move from Askar to Drizzle​

A server that already stores its records in Askar can copy them to Drizzle. The keys stay in Askar. See Migrate from Askar.

To use a storage backend Credo doesn't ship, implement the StorageService interface from @credo-ts/core.