{"id":17044794,"url":"https://github.com/keredson/pouchdb-expo-fix","last_synced_at":"2026-04-16T12:35:28.907Z","repository":{"id":72907944,"uuid":"372568542","full_name":"keredson/pouchdb-expo-fix","owner":"keredson","description":"Fixes so PouchDB will run under Expo / React Native","archived":false,"fork":false,"pushed_at":"2021-06-03T00:37:00.000Z","size":127,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-28T05:41:37.283Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/keredson.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-31T16:30:19.000Z","updated_at":"2021-07-18T18:00:01.000Z","dependencies_parsed_at":"2023-05-26T01:00:20.490Z","dependency_job_id":null,"html_url":"https://github.com/keredson/pouchdb-expo-fix","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/keredson%2Fpouchdb-expo-fix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keredson%2Fpouchdb-expo-fix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keredson%2Fpouchdb-expo-fix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keredson%2Fpouchdb-expo-fix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keredson","download_url":"https://codeload.github.com/keredson/pouchdb-expo-fix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245047614,"owners_count":20552402,"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":[],"created_at":"2024-10-14T09:35:31.596Z","updated_at":"2026-04-16T12:35:23.771Z","avatar_url":"https://github.com/keredson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](logo.png)\n\n# PouchDB Expo Fix\n\n## About\n\n[PouchdB](https://pouchdb.com/) is a database I recently started exploring.  But it sadly\ndoesn't work inside Expo, or worse, fails silently (or with untracable promise errors)\nwhen a document with an attachment is  synced.  This package is a collection of hacks I \nimplemented / pulled from other resources to make it usable.\n\n\n## Installation\n\n### Dependencies\n\nIn your expo app you will need these dependencies:\n\n```bash\n$ yarn add pouchdb-core pouchdb-adapter-http pouchdb-replication \\\n           pouchdb-adapter-utils pouchdb-adapter-websql-core events \\\n           expo-sqlite expo-crypto react-native-get-random-values\n```\n\nAnd of course:\n\n```bash\n$ yarn add pouchdb-expo-fix\n```\n\n### Code Changes\n\nEnable the fixes to PouchDB with the following code:\n\n```javascript\nimport PouchDB from 'pouchdb-core';\nimport PouchDBExpoFix from 'pouchdb-expo-fix';\nrequire('pouchdb-adapter-utils').preprocessAttachments = PouchDBExpoFix.fix_pouchdb_adapter_utils()\nPouchDB.plugin(PouchDBExpoFix.build_sqlite_adapter(require('pouchdb-adapter-websql-core')))\n```\n\nThat should be it, but look out for the possible errors listed below (esp. `FileReader.readAsArrayBuffer`).\n\n## Possible Errors\n\n### Random Values Error\n\nThis project will do the following import for you:\n```javascript\nimport 'react-native-get-random-values'\n```\n\nBut this import must be called **before** `uuid` is imported elsewhere in your app.  If you get:\n\n```javascript\nUnhandled promise rejection: Error: crypto.getRandomValues() not supported.\nSee https://github.com/uuidjs/uuid#getrandomvalues-not-supported\n```\n\nImport it yourself at the top of your `App.js` or whatever the starting point of your app is.\n\n### FileReader.readAsArrayBuffer\n\nIf you see:\n\n```\nPossible Unhandled Promise Rejection (id: 0):\n[Error: FileReader.readAsArrayBuffer is not implemented]\n```\n\nIt's likely coming from `preprocessBlob`, which this is library trys to replace.\nIf you're still getting this error, you likely have another copy of `pouchdb-adapter-utils` about.\n  \nTry `find . | grep pouchdb-adapter-utils` to find all internal versions in your `node_modules` directory.  You may find:\n\n```bash\n$ find . | grep pouchdb-adapter-utils\n./node_modules/pouchdb-adapter-websql-core/node_modules/pouchdb-adapter-utils\n./node_modules/pouchdb-adapter-websql-core/node_modules/pouchdb-adapter-utils/README.md\n./node_modules/pouchdb-adapter-websql-core/node_modules/pouchdb-adapter-utils/package.json\n./node_modules/pouchdb-adapter-websql-core/node_modules/pouchdb-adapter-utils/LICENSE\n./node_modules/pouchdb-adapter-websql-core/node_modules/pouchdb-adapter-utils/lib\n./node_modules/pouchdb-adapter-websql-core/node_modules/pouchdb-adapter-utils/lib/index.es.js\n./node_modules/pouchdb-adapter-websql-core/node_modules/pouchdb-adapter-utils/lib/index.js\n```\n\nThis shows that `pouchdb-adapter-websql-core` is importing its own (likely older) version of\n`pouchdb-adapter-utils`, bypassing our implementation of `preprocessBlob`.  To stop this,\noverride the internal version by setting `resolutions` in `package.json`.\n\nFor example, my `pouchdb-adapter-websql-core` was locked to `pouchdb-adapter-utils`\nversion 7.0.0, not the 7.2.2 that's currently out (and this library is modifying).\nTo fix, I let `pouchdb-adapter-websql-core` use any version greater than 7.0.0 \n(by specifying `\"^7.0.0\"`).\n\n```json\n\"resolutions\": {\n  \"pouchdb-adapter-websql-core/pouchdb-adapter-utils\": \"^7.0.0\"\n}\n```\n\n## Heads Up\n\n### Sets `process.browser`\n\nThis library sets `process.browser = true`.  This prevents the following error:\n\n```javascript\nTypeError: Cannot assign to read only property 'type' of object\n```\n\nThis is a workaround until [this PouchDB bug fix](https://github.com/pouchdb/pouchdb/pull/8255/files)\nmakes it into a release, but it could have side effects elsewhere in your app.\n\n### Overwrites `PouchDB.getAttachment`\n\nThis fix overwrites the implementation of `PouchDB.getAttachment`, to make\n`opts.binary` default to `false` (instead of `true`), which tells PouchDB to use base64 strings\ninstead of `Blob`s and `ArrayBuffer`s.  If you're still getting the following error:\n\n```javascript\nError: Creating blobs from 'ArrayBuffer' and 'ArrayBufferView' are not supported\n```\n\nSearch for other copies of this function with:\n```bash\n$ grep -R \"opts.binary = true\" node_modules/\n```\n\nIf you see more than:\n```\nnode_modules/pouchdb-core/lib/index.es.js:      opts.binary = true;\nnode_modules/pouchdb-core/lib/index.js:      opts.binary = true;\n```\nYou may need to do something like the `FileReader.readAsArrayBuffer` fix above.\n\n### Sets Global Base64\n\nIf `global.btoa` or `global.atob` don't exist in your app, this package will set them for you.\n\n\n## Other Work\n\nNone of these (currently) work in Expo, but I used heavily in building this lib:\n\n- https://medium.com/@duytq94/making-a-simple-note-app-with-pouchdb-in-react-native-ec4810b18a42\n- https://dev.to/craftzdog/created-pouchdb-7-for-react-native-23g6\n- https://github.com/badbod99/pouchdb-expo-example\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeredson%2Fpouchdb-expo-fix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeredson%2Fpouchdb-expo-fix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeredson%2Fpouchdb-expo-fix/lists"}