@powersync/op-sqlite
v0.1.3
Published
PowerSync - sync Postgres or MongoDB with SQLite in your React Native app for offline-first and real-time data
Downloads
430
Readme
OP-SQLite Factory for the PowerSync React Native SDK
Overview
This package (packages/powersync-op-sqlite
) enables using OP-SQLite with PowerSync alongside the React Native SDK.
If you are not yet familiar with PowerSync, please see the PowerSync React Native SDK README for more information.
Alpha release
This package is currently in an alpha release. If you find a bug or issue, please open a GitHub issue. Questions or feedback can be posted on our community Discord - we'd love to hear from you.
Installation
Follow the installation instructions for the React Native SDK if you haven't yet set up PowerSync in your project. However, note that this package cannot be installed alongside @journeyapps/react-native-quick-sqlite
. Skip the step about installing it as a peer dependency, or uninstall it if it is already installed.
Install Package
npx expo install @powersync/op-sqlite
Install Peer Dependency:
This SDK currently requires @op-engineering/op-sqlite
as a peer dependency.
Install it in your app with:
npx expo install @op-engineering/op-sqlite
Usage
import { OPSqliteOpenFactory } from '@powersync/op-sqlite';
import { PowerSyncDatabase } from '@powersync/react-native';
const factory = new OPSqliteOpenFactory({
dbFilename: 'sqlite.db'
});
this.powersync = new PowerSyncDatabase({ database: factory, schema: AppSchema });
Encryption with SQLCipher
To enable SQLCipher you need to add the following configuration option to your application's package.json
{
// your normal package.json
// ...
"op-sqlite": {
"sqlcipher": true
}
}
Additionally you will need to add an encryption key to the OPSQLite factory constructor
const factory = new OPSqliteOpenFactory({
dbFilename: 'sqlite.db',
sqliteOptions: {
encryptionKey: 'your-encryption-key'
}
});
Native Projects
This package uses native libraries. Create native Android and iOS projects (if not created already) by running:
npx expo run:android
# OR
npx expo run:ios