{"id":20945939,"url":"https://github.com/terreii/use-pouchdb","last_synced_at":"2025-05-14T01:31:51.085Z","repository":{"id":37091378,"uuid":"259703199","full_name":"Terreii/use-pouchdb","owner":"Terreii","description":"React Hooks for PouchDB","archived":false,"fork":false,"pushed_at":"2023-07-06T23:17:05.000Z","size":6488,"stargazers_count":69,"open_issues_count":13,"forks_count":4,"subscribers_count":4,"default_branch":"latest","last_synced_at":"2024-11-09T00:34:39.637Z","etag":null,"topics":["couchdb","pouchdb","react","react-hooks","reactjs","typescript"],"latest_commit_sha":null,"homepage":"https://terreii.github.io/use-pouchdb/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Terreii.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-28T17:15:55.000Z","updated_at":"2024-10-29T20:58:54.000Z","dependencies_parsed_at":"2024-08-01T22:41:15.538Z","dependency_job_id":"eb9073ab-a04b-4582-a590-6d225f10e13f","html_url":"https://github.com/Terreii/use-pouchdb","commit_stats":{"total_commits":244,"total_committers":4,"mean_commits":61.0,"dds":"0.061475409836065587","last_synced_commit":"5fbc3960f3ad26c339e4be006b9383cb19f0cb38"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terreii%2Fuse-pouchdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terreii%2Fuse-pouchdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terreii%2Fuse-pouchdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terreii%2Fuse-pouchdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Terreii","download_url":"https://codeload.github.com/Terreii/use-pouchdb/tar.gz/refs/heads/latest","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225269891,"owners_count":17447605,"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":["couchdb","pouchdb","react","react-hooks","reactjs","typescript"],"created_at":"2024-11-18T23:51:18.754Z","updated_at":"2024-11-18T23:51:19.184Z","avatar_url":"https://github.com/Terreii.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# usePouchDB\n\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Known Vulnerabilities](https://snyk.io/test/github/Terreii/use-pouchdb/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Terreii/use-pouchdb?targetFile=package.json)\n[![npm](https://img.shields.io/npm/v/use-pouchdb)](https://www.npmjs.com/package/use-pouchdb)\n\n[React Hooks](https://reactjs.org/) for [PouchDB](https://pouchdb.com/).\n\n## Overview\n\nusePouchDB is a collection of React Hooks to access data in a PouchDB database from React components.\n\nThe goal of usePouchDB is to ease the use of PouchDB with React. Enabling developers to create\n[offline first apps](http://hood.ie/blog/say-hello-to-offline-first.html).\n\n## Quick-start\n\n[You can find the Getting Started docs here](https://christopher-astfalk.de/use-pouchdb) (or on [GitHub](./docs/)).\n\nThese docs walk you through setting up PouchDB and usePouchDB. They give you also a quick\nintroduction to [PouchDB](https://pouchdb.com/) and [Apache CouchDB](https://couchdb.apache.org/).\nBut [PouchDB's Guides](https://pouchdb.com/guides/) are recommended to learn PouchDB.\n\n[You can find a introduction to React here](https://reactjs.org/tutorial/tutorial.html).\n\nIf you know what you're doing and\nonly want to quick start, read on...\n\n### Installation\n\nusePouchDB requires **React 16.8.3 or later**.\n\n```sh\nnpm install use-pouchdb\n# or\nyarn add use-pouchdb\n```\n\nYou'll also need to [install PouchDB](https://pouchdb.com/guides/setup-pouchdb.html 'PouchDBs installation guide').\nThere is also a special [browser version](https://www.npmjs.com/package/pouchdb-browser):\n\n```sh\nnpm install pouchdb-browser\n# or\nyarn add pouchdb-browser\n```\n\nTo use the `useView` hook [`pouchdb-mapreduce`](https://www.npmjs.com/package/pouchdb-mapreduce)\nmust be installed and setup. If you use the [`pouchdb`](https://www.npmjs.com/package/pouchdb) or\n[`pouchdb-browser`](https://www.npmjs.com/package/pouchdb-browser) packages, it is already setup.\n\n```sh\nnpm install pouchdb-mapreduce\n# or\nyarn add pouchdb-mapreduce\n```\n\nFor using the `useFind` hook [`pouchdb-find`](https://www.npmjs.com/package/pouchdb-find)\nmust be installed and setup.\n\n```sh\nnpm install pouchdb-find\n# or\nyarn add pouchdb-find\n```\n\n### Bind usePouchDB\n\nusePouchDB exports a `\u003cProvider /\u003e` to make one or multiple PouchDB databases available to its\ncomponents sub-tree.\n\n```jsx\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport PouchDB from 'pouchdb-browser'\n\nimport { Provider } from 'use-pouchdb'\n\nimport App from './App'\n\nconst db = new PouchDB('local')\n\nReactDOM.render(\n  \u003cProvider pouchdb={db}\u003e\n    \u003cApp /\u003e\n  \u003c/Provider\u003e,\n  document.getElementById('root')\n)\n```\n\n### Hooks\n\n[All hooks are listed here](https://christopher-astfalk.de/use-pouchdb/docs/introduction/quick_start).\n\n- [`usePouch`](https://christopher-astfalk.de/use-pouchdb/docs/api/use-pouch) - Access the database\n  provided by `\u003cProvider /\u003e`.\n- [`useDoc`](https://christopher-astfalk.de/use-pouchdb/docs/api/use-doc) - Access a single document\n  and subscribe to its changes. The hook version of [`db.get`](https://pouchdb.com/api.html#fetch_document).\n- [`useAllDocs`](https://christopher-astfalk.de/use-pouchdb/docs/api/use-all-docs) - Load multiple documents\n  and subscribe to their changes. Or a range of docs by their ids. The hook version of\n  [`db.allDocs`](https://pouchdb.com/api.html#batch_fetch).\n- [`useFind`](https://christopher-astfalk.de/use-pouchdb/docs/api/use-find) - Access a mango index and\n  subscribe to it. Optionally create the index, if it doesn't exist. The hook version of\n  [`db.createIndex`](https://pouchdb.com/api.html#create_index) and\n  [`db.find`](https://pouchdb.com/api.html#query_index) combined.\n- [`useView`](https://christopher-astfalk.de/use-pouchdb/docs/api/use-view) - Access a view and subscribe\n  to its changes. The hook version of [`db.query`](https://pouchdb.com/api.html#query_database).\n\n### Example\n\nLoad a single document and display it. [`useDoc`](https://christopher-astfalk.de/use-pouchdb/docs/api/use-doc)\nis the hook version of [`db.get`](https://pouchdb.com/api.html#fetch_document), but it also\nsubscribes to updates of that document and automatically loads the new version.\n\n```jsx\nimport React from 'react'\nimport { useDoc } from 'use-pouchdb'\n\nexport default function Post({ postId }) {\n  const { doc, loading, error } = useDoc(postId)\n\n  if (error \u0026\u0026 !loading) {\n    return \u003cdiv\u003esomething went wrong: {error.name}\u003c/div\u003e\n  }\n\n  if (doc == null \u0026\u0026 loading) {\n    return null\n  }\n\n  return (\n    \u003carticle\u003e\n      \u003cdiv\u003e\n        \u003ch3\u003e{doc.author}\u003c/h3\u003e\n        \u003cp\u003e{doc.text}\u003c/p\u003e\n      \u003c/div\u003e\n    \u003c/article\u003e\n  )\n}\n```\n\n## Changelog\n\nusePouchDB follows [semantic versioning](https://semver.org/). To see a changelog with all\nusePouchDB releases, check out the\n[Github releases page](https://github.com/Terreii/use-pouchdb/releases).\n\n## Contributing\n\nContributions in all forms are welcomed. ♡\n\nIf you have questions, [Contributing.md](https://github.com/Terreii/use-pouchdb/blob/latest/CONTRIBUTING.md) might answer your questions.\n\nTo create a welcoming project to all, this project uses and enforces a\n[Code of Conduct](https://github.com/Terreii/use-pouchdb/blob/latest/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterreii%2Fuse-pouchdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterreii%2Fuse-pouchdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterreii%2Fuse-pouchdb/lists"}