@decentrasol/react-orbitdb
v0.2.1
Published
[![](https://img.shields.io/badge/License-Apache--2.0-yellow.svg)](https://opensource.org/licenses/Apache-2.0) [![](https://img.shields.io/npm/v/react-orbitdb.svg)](https://www.npmjs.com/package/react-orbitdb)
Downloads
12
Readme
react-orbitdb
react hooks and providers for dealing with IPFS orbit-db datasources.
You can see a demo here : https://revolunet.github.io/react-orbitdb
Provider
OrbitProvider
creates a shared IPFS Node and an orbit-db instance.
import { OrbitProvider } from "@decentrasol/react-orbitdb";
const App = () => <OrbitProvider>...</OrbitProvider>;
config
prop with ipfs configuration can be passed to the provider. (see the default)
Hooks
useOrbitDb
useOrbitDb
connects and return records from an OrbitDB database. records
are updated in real-time.
import { useOrbitDb } from "@decentrasol/react-orbitdb";
const MyCmp = () => {
const { db, records } = useOrbitDb("/orbitdb/somehash/my-db, {
create: true,
type: 'eventlog'
});
return (
<div>
{records &&
records.map((record) => <div key={record.id}>{record.message}</div>)}
</div>
);
};
options
: OrbitDB.open options- the
options.create
andoptions.public
values set the database world-writeable when you first create it.
- the
useOrbit
useOrbit
is included in OrbitProvider
, you should not need it
useIpfs
useIpfs
is included in OrbitProvider
, you should not need it
Development
- Checkout this repo
- Run
yarn
- Run
yarn start
to run example - Run
yarn build
to build example