Download the appropriate pre-built binary for your platform from the official Releases page:
- Linux: x86 and ARM
- macOS: x86 and ARM
- Windows: x86
- Android
- iOS
-- In SQLite CLI
.load ./cloudsync
-- In SQL
SELECT load_extension('./cloudsync');Add this repository as a package dependency to your Swift project. After adding the package, set up SQLite with extension loading by following steps 4 and 5 of this guide.
import CloudSync
var db: OpaquePointer?
sqlite3_open(":memory:", &db)
sqlite3_enable_load_extension(db, 1)
var errMsg: UnsafeMutablePointer<Int8>? = nil
sqlite3_load_extension(db, CloudSync.path, nil, &errMsg)
var stmt: OpaquePointer?
sqlite3_prepare_v2(db, "SELECT cloudsync_version()", -1, &stmt, nil)
defer { sqlite3_finalize(stmt) }
sqlite3_step(stmt)
log("cloudsync_version(): \(String(cString: sqlite3_column_text(stmt, 0)))")
sqlite3_close(db)Add the following to your Gradle dependencies:
implementation 'ai.sqlite:sync:1.0.0'SQLiteCustomExtension cloudsyncExtension = new SQLiteCustomExtension(
getApplicationInfo().nativeLibraryDir + "/cloudsync", null);
SQLiteDatabaseConfiguration config = new SQLiteDatabaseConfiguration(
getCacheDir().getPath() + "/cloudsync_test.db",
SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.OPEN_READWRITE,
Collections.emptyList(),
Collections.emptyList(),
Collections.singletonList(cloudsyncExtension)
);
SQLiteDatabase db = SQLiteDatabase.openDatabase(config, null, null);For full implementation details, see the complete Android example.
Install the Expo package:
npm install @sqliteai/sqlite-sync-expoAdd to your app.json:
{
"expo": {
"plugins": ["@sqliteai/sqlite-sync-expo"]
}
}Run prebuild:
npx expo prebuild --cleanLoad the extension:
import { Platform } from 'react-native';
import { getDylibPath, open } from '@op-engineering/op-sqlite';
const db = open({ name: 'mydb.db' });
// Load SQLite Sync extension
if (Platform.OS === 'ios') {
const path = getDylibPath('ai.sqlite.cloudsync', 'CloudSync');
db.loadExtension(path);
} else {
db.loadExtension('cloudsync');
}Install the React Native library:
npm install @sqliteai/sqlite-sync-react-nativeThen follow the instructions from the README.
Add the sqlite_sync package to your project:
flutter pub add sqlite_sync # Flutter projects
dart pub add sqlite_sync # Dart projectsimport 'package:sqlite3/sqlite3.dart';
import 'package:sqlite_sync/sqlite_sync.dart';
sqlite3.loadSqliteSyncExtension();
final db = sqlite3.openInMemory();
print(db.select('SELECT cloudsync_version()'));For a complete example, see the Flutter example.
The WebAssembly version of SQLite with the SQLite Sync extension is available on npm:
npm install @sqliteai/sqlite-wasmSee the npm package for usage details.