Registry / database / pouchdb-adapter-react-native-sqlite

pouchdb-adapter-react-native-sqlite

JSON →
library4.1.3jsnpmunverified

A PouchDB adapter that uses op-sqlite as the backing store on React Native, replacing AsyncStorage for better performance. Version 4.1.3 is the latest stable release, with infrequent updates. It requires polyfilling Node.js modules (crypto, stream, buffer) and bundler aliasing. Unlike other SQLite adapters, it directly binds to op-sqlite for efficiency and supports SQLCipher encryption.

npm install pouchdb-adapter-react-native-sqlite
INSTALL
IMPORT
SIG · POUCHDB-ADAPTER-RE
P
pouchdb-adapter-react-native-sqlite
databasejavascriptv4.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sqliteAdapter
import sqliteAdapter from 'pouchdb-adapter-react-native-sqlite'
const sqliteAdapter = require('pouchdb-adapter-react-native-sqlite')
Default import only; CommonJS require is not supported as the package is ESM-only.
PouchDB
import PouchDB from 'pouchdb-core'
const PouchDB = require('pouchdb-core')
PouchDB core is ESM-only; use import or dynamic import.
sqliteAdapter (plugin)
PouchDB.plugin(sqliteAdapter).plugin(HttpPouch).plugin(replication).plugin(mapreduce)
PouchDB.plugin(sqliteAdapter).plugin('pouchdb-adapter-http')
Chain plugins in correct order: adapter first, then plugins like http, replication, mapreduce.

Sets up PouchDB with react-native-sqlite adapter including polyfills and plugin registration.

// shim.ts import { install } from 'react-native-quick-crypto'; install(); // pouchdb.ts import PouchDB from 'pouchdb-core'; import HttpPouch from 'pouchdb-adapter-http'; import replication from 'pouchdb-replication'; import mapreduce from 'pouchdb-mapreduce'; import sqliteAdapter from 'pouchdb-adapter-react-native-sqlite'; export default PouchDB.plugin(HttpPouch) .plugin(replication) .plugin(mapreduce) .plugin(sqliteAdapter); // usage import PouchDB from './pouchdb'; const db = new PouchDB('mydb', { adapter: 'react-native-sqlite' }); await db.put({ _id: 'doc1', value: 'test' }); const doc = await db.get('doc1'); console.log(doc);
Debug
Known issues
breakingv4.0.0 dropped dependency on @craftzdog/pouchdb-adapter-websql-core and now directly uses op-sqlite. Update imports and remove old package.
fix
Remove @craftzdog/pouchdb-adapter-websql-core from package.json; ensure op-sqlite is installed.
affects: >=4.0.0
deprecatedUsage of AsyncStorage-based adapter is deprecated; this adapter is the official replacement.
fix
Migrate to using 'react-native-sqlite' adapter.
affects: >=4.0.0
gotchaRequires polyfill for Node.js crypto, buffer, and stream. Failure to install these will cause runtime errors.
fix
Install react-native-quick-crypto, @craftzdog/react-native-buffer, readable-stream, and configure babel-plugin-module-resolver as per README.
affects: >=4.0.0
gotchaWhen new architecture is enabled, react-native-quick-crypto's install() may fail with 'React Native is not running on-device' error.
fix
Edit NativeQuickCrypto.js to comment out the on-device check as described in troubleshooting.
affects: >=4.0.0
gotchaAdapter name is 'react-native-sqlite' (lowercase, hyphenated). Using wrong adapter name will throw 'adapter is not a function'.
fix
Use adapter: 'react-native-sqlite' when creating PouchDB instance.
affects: >=4.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'install' of undefined
Missing or failed installation of react-native-quick-crypto polyfill.
fix
Ensure react-native-quick-crypto is installed and import 'react-native-quick-crypto' and call install() in shim.ts.
Error: adapter 'react-native-sqlite' is not a function
Adapter not properly imported or registered via PouchDB.plugin().
fix
Import sqliteAdapter from 'pouchdb-adapter-react-native-sqlite' and call PouchDB.plugin(sqliteAdapter) before creating PouchDB instances.
Error: Failed to install react-native-quick-crypto: React Native is not running on-device. QuickCrypto can only be used when synchronous method invocations (JSI) are possible.
Running on remote debugger (Chrome) or new architecture without proper polyfill.
fix
Switch to on-device debugger (Flipper) or edit NativeQuickCrypto.js to bypass the check as per troubleshooting.
Module 'crypto' not found. Consider using 'react-native-quick-crypto' instead.
Missing babel-plugin-module-resolver configuration to alias crypto module.
fix
Install babel-plugin-module-resolver and add alias in babel.config.js as per README.
Upgrade
Version history
4.1.3latest on npm
Audit
Dependencies
@op-engineering/op-sqliterequiredSQLite native library for React Native
react-native-quick-cryptorequiredPolyfill for Node.js crypto module
@craftzdog/react-native-bufferrequiredPolyfill for Node.js buffer module
@craftzdog/pouchdb-errorsrequiredCustom pouchdb-errors polyfill
readable-streamoptionalPolyfill for Node.js stream module
Agent activity
41 hits · last 30 days
node
34
Resources
pouchdb-adapter-react-native-sqlite — npm install pouchdb-adapter-react-native-sqlite · libregistry