This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
React Native SQLCipher Storage — encrypted SQLite (SQLCipher) bindings for React Native with a unified JavaScript API across iOS, Android, Windows, and Electron. Forked from react-native-sqlite-storage, adapted from Cordova-sqlcipher-adapter.
- Lint:
npm run lint(ESLint with Prettier via@react-native/eslint-config) - Run example (Android):
npm run start:android - Run example (iOS):
npm run start:ios
The library exposes a single JS API that delegates to platform-specific native modules via React Native's bridge (or Electron IPC).
src/sqlite.core.js— Core runtime:SQLitePlugin(database handle),SQLitePluginTransaction(transaction queue with lock management), andSQLiteFactory(open/delete databases). Dispatches calls to native modules viaplugin.exec(). On web/Electron, routes towindow.sqliteapi(exposed by the preload script); on native platforms, routes toNativeModules.SQLite.src/index.js— Promise/callback adapter. Wrapssqlite.core.jsclasses so that callingenablePromise(true)switches the API from callback-style to Promise-style. Exports a singletonSQLiteFactoryinstance as the default export.src/index.d.ts— TypeScript type definitions.
Each platform implements the same four operations: open, close, delete, backgroundExecuteSqlBatch.
- iOS (
ios/SQLite.m) — Objective-CRCTBridgeModule. Links against SQLCipher viaSQLITE_HAS_CODEC=1preprocessor flag and CocoaPodsSQLCipher ~>4.0. - Android (
android/src/main/java/com/axsy/) — Java React Native module. Usesnet.zetetic:android-database-sqlcipher:4.4.2with a thread pool andConcurrentHashMapfor concurrent database management. - Windows (
windows/) — C++ WinRT implementation requiring OpenSSL build. - Electron (
electron/) — Three-file IPC architecture:main.js— Main process:SQLiteclass wraps@journeyapps/sqlcipherwith async wrappers (AsyncDatabase,AsyncStatement). Registers IPC handlers viadb.main.init().preload.js— Context bridge: exposeswindow.sqliteapito renderer viacontextBridge.exposeInMainWorld(). Initialize withdb.preload.init().renderer.js— Thin proxy: exportselectronAPIobject that forwards calls towindow.sqliteapi.
"." → ./src/index.js (main library)
"./preload" → ./electron/preload.js (Electron preload script)
"./main" → ./electron/main.js (Electron main process)
Transactions are queued per-database in txLocks (keyed by db name). Each lock tracks a FIFO queue and an inProgress flag. Locked transactions automatically wrap statements in BEGIN/COMMIT/ROLLBACK. Statements within a transaction are batched and sent to the native layer via backgroundExecuteSqlBatch.
- ES Modules (
"type": "module"in package.json) - No TypeScript compilation — source is plain JS with JSDoc type annotations and a separate
.d.tsfile - Prettier 2.8.8 formatting enforced through ESLint