Skip to content

YJS persistence provider for op-sqlite

Notifications You must be signed in to change notification settings

malte-j/y-op-sqlite

Repository files navigation

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.

About

YJS persistence provider for op-sqlite

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published