y-op-sqlite
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

About

y-op-sqlite is a persistence provider for Yjs that uses op-sqlite to store document changes in a SQLite database. This is useful for React Native projects that need to access YJS documents without an internet connection to enable a local-first experience.

Installing

You can install y-op-sqlite and its peer dependencies using expo:

# install using expo
npx expo install y-op-sqlite yjs @op-engineering/op-sqlite

Or alternatively using npm:

# install using npm
npm i y-op-sqlite yjs @op-engineering/op-sqlite

Make sure to check the op-sqlite docs for instructions on setting up op-sqlite in your React Native project.

Usage

import { OPSQLitePersistence } from 'y-op-sqlite';

// other code...

const provider = new OPSQLitePersistence(docName, ydoc);

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-indexdb by Kevin Jahns. Thanks to @ospfranco for creating op-sqlite.

Package Sidebar

Install

npm i y-op-sqlite

Weekly Downloads

8

Version

1.0.4

License

MIT

Unpacked Size

6.9 kB

Total Files

6

Last publish

Collaborators

  • malte_