y-cap-sqlite
v1.0.0
Published
y-cap-sqlite is a persistence provider for [Yjs](https://github.com/yjs/yjs) that uses [@capacitor-community/sqlite](https://github.com/capacitor-community/sqlite) to store document changes in a SQLite database. This is useful for Capacitor projects that
Maintainers
Readme
About
y-cap-sqlite is a persistence provider for Yjs that uses @capacitor-community/sqlite to store document changes in a SQLite database. This is useful for Capacitor projects that need to access YJS documents without an internet connection to enable a local-first experience.
Installing
You can install y-cap-sqlite and its peer dependencies using your favorite package manager:
# install using npm
npm install ls yjs @capacitor-community/sqlite
# install using bun
bun add y-cap-sqlite yjs @capacitor-community/sqlite
# install using pnpm
pnpm add y-cap-sqlite yjs @capacitor-community/sqliteUsage
import { CapSQLitePersistence } from 'y-cap-sqlite';
// other code...
const provider = await OPSQLitePersistence.create(config: Omit<capConnectionOptions, "database">, doc: Y.Doc, name: string, sqlite: SQLiteConnection);
provider.whenSynced.then(() => {
console.log("content finished loading from database.");
});When you're done accessing the document, you can destroy the connection to the provider:
// stop syncing with database
provider.destroy();Attribution
This library is based on y-op-sqlite by Malte J, thanks to him for the support !
