{"id":4698,"url":"https://github.com/craftzdog/pouchdb-adapter-react-native-sqlite","last_synced_at":"2025-04-09T13:07:20.505Z","repository":{"id":14734223,"uuid":"76961176","full_name":"craftzdog/pouchdb-adapter-react-native-sqlite","owner":"craftzdog","description":"PouchDB adapter using ReactNative SQLite as its backing store","archived":false,"fork":false,"pushed_at":"2023-04-17T18:54:52.000Z","size":161,"stargazers_count":116,"open_issues_count":7,"forks_count":20,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-22T01:55:31.523Z","etag":null,"topics":["database","pouchdb","react-native","sqlite3"],"latest_commit_sha":null,"homepage":"https://github.com/craftzdog/pouchdb-react-native","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/craftzdog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-12-20T14:00:17.000Z","updated_at":"2024-03-03T15:54:49.000Z","dependencies_parsed_at":"2024-01-09T07:42:52.829Z","dependency_job_id":"7f5cc117-f6df-4fe8-bbdc-cde80974636c","html_url":"https://github.com/craftzdog/pouchdb-adapter-react-native-sqlite","commit_stats":{"total_commits":24,"total_committers":4,"mean_commits":6.0,"dds":"0.45833333333333337","last_synced_commit":"95eaab0968f38a6d913ea70c2621a18fce6e7a6f"},"previous_names":["noradaiko/pouchdb-adapter-react-native-sqlite"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Fpouchdb-adapter-react-native-sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Fpouchdb-adapter-react-native-sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Fpouchdb-adapter-react-native-sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Fpouchdb-adapter-react-native-sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/craftzdog","download_url":"https://codeload.github.com/craftzdog/pouchdb-adapter-react-native-sqlite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045231,"owners_count":21038553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","pouchdb","react-native","sqlite3"],"created_at":"2024-01-05T20:17:20.610Z","updated_at":"2025-04-09T13:07:20.481Z","avatar_url":"https://github.com/craftzdog.png","language":"JavaScript","funding_links":[],"categories":["Components","TypeScript"],"sub_categories":["Storage"],"readme":"# pouchdb-adapter-react-native-sqlite\n\nPouchDB adapter using [op-sqlite](https://github.com/OP-Engineering/op-sqlite) as its backing store on React Native.\nIt's much faster than AsyncStorage.\n\nAs of v4.0.0, it no longer requires `@craftzdog/pouchdb-adapter-websql-core`.\nIt now directly uses op-sqlite, so it's more efficient.\n\n## How to use\n\n### Installation\n\n```sh\nyarn add @op-engineering/op-sqlite react-native-quick-crypto @craftzdog/react-native-buffer\n```\n\n### Polyfill NodeJS APIs\n\nCreate a `shim.ts` file like so:\n\n```ts\nimport { install } from 'react-native-quick-crypto'\n\ninstall()\n```\n\nConfigure babel to use the shim modules. First, you need to install `babel-plugin-module-resolver`.\n\n```sh\nyarn add --dev babel-plugin-module-resolver\n```\n\nThen, in your `babel.config.js`, add the plugin to swap the `crypto`, `stream` and `buffer` dependencies:\n\n```js\n    plugins: [\n      [\n        'module-resolver',\n        {\n          extensions: ['.tsx', '.ts', '.js', '.json'],\n          alias: {\n            crypto: 'react-native-quick-crypto',\n            stream: 'readable-stream',\n            buffer: '@craftzdog/react-native-buffer',\n          },\n        },\n      ],\n    ],\n```\n\nThen restart your bundler using `yarn start --reset-cache`.\n\n### Install PouchDB and adapter\n\nNow it's ready to use PouchDB!\n\n```sh\nyarn add pouchdb-core pouchdb-mapreduce pouchdb-replication pouchdb-adapter-http pouchdb-adapter-react-native-sqlite\n```\n\nCreate `pouchdb.ts`:\n\n```ts\nimport PouchDB from 'pouchdb-core'\nimport HttpPouch from 'pouchdb-adapter-http'\nimport replication from 'pouchdb-replication'\nimport mapreduce from 'pouchdb-mapreduce'\nimport sqliteAdapter from 'pouchdb-adapter-react-native-sqlite'\n\nexport default PouchDB.plugin(HttpPouch)\n  .plugin(replication)\n  .plugin(mapreduce)\n  .plugin(sqliteAdapter)\n```\n\n### How to use PouchDB\n\n```ts\nimport PouchDB from './pouchdb'\n\nconst pouch = new PouchDB('mydb', {\n  adapter: 'react-native-sqlite',\n})\n```\n\n## Troubleshootings\n\n### Fails to install crypto shim with `install()` on launch\n\nYou amy get the following error when new arch is enabled:\n\n```\n (NOBRIDGE) ERROR  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. If you are using a remote debugger (e.g. Chrome), switch to an on-device debugger (e.g. Flipper) instead.\n (NOBRIDGE) ERROR  TypeError: Cannot read property 'install' of undefined\n```\n\n- This is a know issue: [Error: Failed to install react-native-quick-crypto: React Native is not running on-device. · Issue #333 · margelo/react-native-quick-crypto · GitHub](https://github.com/margelo/react-native-quick-crypto/issues/333)\n\nFor now, you have to edit:\n\n- `lib/module/NativeQuickCrypto/NativeQuickCrypto.js`\n\nAnd comment them out:\n\n```\n  // Check if we are running on-device (JSI)\n  // if (global.nativeCallSyncHook == null || QuickCryptoModule.install == null) {\n  //   throw new 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. If you are using a remote debugger (e.g. Chrome), switch to an on-device debugger (e.g. Flipper) instead.');\n  // }\n```\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n## License\n\nMIT © Takuya Matsuyama\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraftzdog%2Fpouchdb-adapter-react-native-sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcraftzdog%2Fpouchdb-adapter-react-native-sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraftzdog%2Fpouchdb-adapter-react-native-sqlite/lists"}