{"id":13472526,"url":"https://github.com/craftzdog/pouchdb-react-native","last_synced_at":"2025-03-26T17:30:41.605Z","repository":{"id":37649228,"uuid":"177566870","full_name":"craftzdog/pouchdb-react-native","owner":"craftzdog","description":":koala: - PouchDB is a pocket-sized database, with some patches for running on React Native","archived":false,"fork":true,"pushed_at":"2024-12-06T01:37:37.000Z","size":120728,"stargazers_count":64,"open_issues_count":1,"forks_count":12,"subscribers_count":5,"default_branch":"v7","last_synced_at":"2025-03-17T21:49:29.199Z","etag":null,"topics":["database","pouchdb","react-native"],"latest_commit_sha":null,"homepage":"https://pouchdb.com/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"pouchdb/pouchdb","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/craftzdog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-25T10:46:04.000Z","updated_at":"2025-01-24T04:07:59.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/craftzdog/pouchdb-react-native","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Fpouchdb-react-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Fpouchdb-react-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Fpouchdb-react-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Fpouchdb-react-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/craftzdog","download_url":"https://codeload.github.com/craftzdog/pouchdb-react-native/tar.gz/refs/heads/v7","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245702124,"owners_count":20658549,"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"],"created_at":"2024-07-31T16:00:55.413Z","updated_at":"2025-03-26T17:30:40.908Z","avatar_url":"https://github.com/craftzdog.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# [PouchDB](https://pouchdb.com/) for React Native\n\nA performant fork of PouchDB for React Native.\n\n**NOTE**: The attachment support has been dropped since I no longer store binary data in PouchDB.\n\n## How to use PouchDB on React Native with SQLite\n\n### Install\n\n1. Install dev package:\n\n   ```\n   yarn add -D babel-plugin-module-resolver\n   ```\n\n2. Install polyfill packages:\n\n   ```sh\n   yarn add events react-native-get-random-values react-native-quick-base64\n   ```\n\n3. Install pouchdb packages:\n\n   ```sh\n   yarn add pouchdb-core pouchdb-replication pouchdb-mapreduce pouchdb-adapter-http\n   ```\n\n4. Install patched package:\n\n   ```sh\n   yarn add @craftzdog/pouchdb-collate-react-native\n   ```\n\n   It avoids using ['\\u0000' chars](https://github.com/facebook/react-native/issues/12731) for indexing (See [this commit](https://github.com/craftzdog/pouchdb-react-native/commit/228f68220fe31236f6630b71c030eef29ae6e7a8)).\n   \n\n4. Install storage adapter packages:\n\n   ```sh\n   yarn add pouchdb-adapter-react-native-sqlite react-native-quick-sqlite react-native-quick-websql\n   ```\n\n   - [react-native-quick-sqlite](https://github.com/ospfranco/react-native-quick-sqlite) - A fast bindings via JSI for SQLite\n   - [react-native-quick-websql](https://github.com/craftzdog/react-native-quick-websql/) - WebSQL wrapper for quick-sqlite\n   - [pouchdb-adapter-react-native-sqlite](https://github.com/craftzdog/pouchdb-adapter-react-native-sqlite) - PouchDB adapter for SQLite with those two modules\n\n5. Install CocoaPods:\n\n   ```sh\n   npx pod-install\n   ```\n\n### Configure\n\n1. Make a `shim.js`:\n\n   ```js\n   import {shim} from 'react-native-quick-base64'\n\n   shim()\n\n   // Avoid using node dependent modules\n   process.browser = true\n   ```\n\n   then, require it at the beginning of your `index.js`.\n\n2. Edit your `babel.config.js` like so:\n\n   ```\n   module.exports = {\n     presets: ['module:metro-react-native-babel-preset'],\n     plugins: [\n       [\n         'module-resolver',\n         {\n           alias: {\n             'pouchdb-collate': '@craftzdog/pouchdb-collate-react-native',\n           },\n         },\n       ],\n     ],\n   }\n   ```\n\n### Initialize\n\nCreate `pouchdb.ts` like so:\n\n```ts\nimport 'react-native-get-random-values'\nimport PouchDB from 'pouchdb-core'\nimport HttpPouch from 'pouchdb-adapter-http'\nimport replication from 'pouchdb-replication'\nimport mapreduce from 'pouchdb-mapreduce'\nimport SQLiteAdapterFactory from 'pouchdb-adapter-react-native-sqlite'\nimport WebSQLite from 'react-native-quick-websql'\n\nconst SQLiteAdapter = SQLiteAdapterFactory(WebSQLite)\n\nexport default PouchDB.plugin(HttpPouch)\n  .plugin(replication)\n  .plugin(mapreduce)\n  .plugin(SQLiteAdapter)\n```\n\nThen, import and use it as usual:\n\n```ts\nimport PouchDB from './pouchdb'\n\nconst db = new PouchDB('mydb.db', {\n  adapter: 'react-native-sqlite'\n})\n```\n\n## Contributing\n\nWe're always looking for new contributors! If you'd like to try your hand at writing code, writing documentation, designing the website, writing a blog post, or answering [questions on StackOverflow](http://stackoverflow.com/search?tab=newest\u0026q=pouchdb), then we'd love to have your input.\n\nIf you have a pull request that you'd like to submit, please read the [contributing guide](https://github.com/pouchdb/pouchdb/blob/master/CONTRIBUTING.md) for info on style, commit message format, and other (slightly!) nitpicky things like that. PouchDB is heavily tested, so you'll also want to check out the [testing guide](https://github.com/pouchdb/pouchdb/blob/master/TESTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraftzdog%2Fpouchdb-react-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcraftzdog%2Fpouchdb-react-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraftzdog%2Fpouchdb-react-native/lists"}