# @sqliteai/sqlite-sync-expo

SQLite Sync extension for Expo apps.

**Version:** 0.9.62

This package provides pre-built SQLite Sync binaries for iOS and Android, along with an Expo config plugin that automatically configures your native projects.

## Installation

```bash
npm install @sqliteai/sqlite-sync-expo @op-engineering/op-sqlite
# or
yarn add @sqliteai/sqlite-sync-expo @op-engineering/op-sqlite
```

## Setup

### 1. Add Plugin to app.json

```json
{
  "expo": {
    "plugins": ["@sqliteai/sqlite-sync-expo"]
  }
}
```

### 2. Run Prebuild

```bash
npx expo prebuild --clean
```

The plugin will automatically:
- **iOS**: Copy `CloudSync.xcframework` and add it to your Xcode project with embed & sign
- **Android**: Copy `cloudsync.so` files to `jniLibs` for each architecture

### 3. Load Extension in Code

```typescript
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') {
  // iOS requires the bundle ID and framework name
  const path = getDylibPath('ai.sqlite.cloudsync', 'CloudSync');
  db.loadExtension(path);
} else {
  // Android just needs the library name
  db.loadExtension('cloudsync');
}

// Verify it works
const result = db.executeSync('SELECT cloudsync_version() as version');
console.log('SQLite Sync Version:', result.rows[0].version);
```

## Supported Platforms

### iOS
- arm64 (devices)
- arm64 + x86_64 simulator

### Android
- arm64-v8a
- armeabi-v7a
- x86_64

## Requirements

- Expo SDK 51+
- React Native 0.73+
- [@op-engineering/op-sqlite](https://www.npmjs.com/package/@op-engineering/op-sqlite) for loading extensions

## Links

- [SQLite Sync Documentation](https://github.com/sqliteai/sqlite-sync)
- [SQLite Cloud](https://sqlitecloud.io)

## License

See [LICENSE.md](./LICENSE.md)
