castorinop / react-orbitdb

react hooks and providers for dealing with ipfs orbit-db datasources

Home Page:https://revolunet.github.io/react-orbitdb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 "react-orbitdb";

const App = () => <OrbitProvider>...</OrbitProvider>;

Hooks

useOrbitDb

useOrbitDb connects and return records from an OrbitDB database. records are updated in real-time.

import { useOrbitDb } from "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 and options.public values set the database world-writeable when you first create it.

useOrbit

useOrbit is included in OrbitProvider, you should not need it

useIpfs

useIpfs is included in OrbitProvider, you should not need it

About

react hooks and providers for dealing with ipfs orbit-db datasources

https://revolunet.github.io/react-orbitdb


Languages

Language:JavaScript 97.5%Language:HTML 2.5%