Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
use-pouchdb
Advanced tools
React Hooks for PouchDB.
usePouchDB is a collection of React Hooks to access data in a PouchDB database from React components.
The goal of usePouchDB is to ease the use of PouchDB with React. Enabling developers to create offline first apps.
You can find the Getting Started docs here (or on GitHub).
These docs walk you through setting up PouchDB and usePouchDB. They give you also a quick introduction to PouchDB and Apache CouchDB. But PouchDB's Guides are recommended to learn PouchDB.
You can find a introduction to React here.
If you know what you're doing and only want to quick start, read on...
usePouchDB requires React 16.8.3 or later.
npm install use-pouchdb
# or
yarn add use-pouchdb
You'll also need to install PouchDB. There is also a special browser version:
npm install pouchdb-browser
# or
yarn add pouchdb-browser
To use the useView
hook pouchdb-mapreduce
must be installed and setup. If you use the pouchdb
or
pouchdb-browser
packages, it is already setup.
npm install pouchdb-mapreduce
# or
yarn add pouchdb-mapreduce
For using the useFind
hook pouchdb-find
must be installed and setup.
npm install pouchdb-find
# or
yarn add pouchdb-find
usePouchDB exports a <Provider />
to make one or multiple PouchDB databases available to its
components sub-tree.
import React from 'react'
import ReactDOM from 'react-dom'
import PouchDB from 'pouchdb-browser'
import { Provider } from 'use-pouchdb'
import App from './App'
const db = new PouchDB('local')
ReactDOM.render(
<Provider pouchdb={db}>
<App />
</Provider>,
document.getElementById('root')
)
usePouch
- Access the database
provided by <Provider />
.useDoc
- Access a single document
and subscribe to its changes. The hook version of db.get
.useAllDocs
- Load multiple documents
and subscribe to their changes. Or a range of docs by their ids. The hook version of
db.allDocs
.useFind
- Access a mango index and
subscribe to it. Optionally create the index, if it doesn't exist. The hook version of
db.createIndex
and
db.find
combined.useView
- Access a view and subscribe
to its changes. The hook version of db.query
.Load a single document and display it. useDoc
is the hook version of db.get
, but it also
subscribes to updates of that document and automatically loads the new version.
import React from 'react'
import { useDoc } from 'use-pouchdb'
export default function Post({ postId }) {
const { doc, loading, error } = useDoc(postId)
if (error && !loading) {
return <div>something went wrong: {error.name}</div>
}
if (doc == null && loading) {
return null
}
return (
<article>
<div>
<h3>{doc.author}</h3>
<p>{doc.text}</p>
</div>
</article>
)
}
usePouchDB follows semantic versioning. To see a changelog with all usePouchDB releases, check out the Github releases page.
Contributions in all forms are welcomed. ♡
If you have questions, Contributing.md might answer your questions.
To create a welcoming project to all, this project uses and enforces a Code of Conduct.
FAQs
React Hooks for PouchDB
The npm package use-pouchdb receives a total of 101 weekly downloads. As such, use-pouchdb popularity was classified as not popular.
We found that use-pouchdb demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.