⛔️ DEPRECATED
This library is being deprecated and replaced with more flexible ipfs-provider.
This library will not be maintained.
ipfs-redux-bundle
A redux bundle to create an IPFS instance and pass it as an
extraArg
to other store methods.
See https://reduxbundler.com for more info on the wonders of redux bundles.
This module tries to connect to IPFS via multiple providers, in order:
ipfs-companion
the IPFS instance from IPFS Companion directly.window.ipfs
in the current page via IPFS Companion.js-ipfs-http-client
with either a user providedapiAddress
, the current origin, or the default/ip4/127.0.0.1/tcp/5001
address.js-ipfs
disabled by default. PasstryJsIpfs: true, getJsIpfs: () => Promise
to enable it. See Enable js-ipfs
Usage
Add ipfs-redux-bundle
to your store
bundles/index.js
// ... import other bundles // ... add bundles here
In your app, you can now connect
up the doInitIpfs
function. Here we init IPFS when our root component mounts:
App.js
{ thisprops } { // ipfs-css powered gorgeous ui here. } 'doInitIpfs' App
Enable js-ipfs
To enable js-ipfs, intialise the bundle with the following opts
tryJsIpfs
should be set totrue
getJsIpfs
should be a function that returns a promise that resolves with aJsIpfs
constructor. This works well with dynamicimport()
, so you can lazily load js-ipfs when it is needed.
API
Adds the following methods to the redux store.
store.selectIpfsReady()
boolean
- Is the IPFS instance ready to use yet?
store.selectIpfsInitFailed()
boolean
- Did the IPFS instance fail to start?
store.selectIpfsInvalidAddress()
boolean
- Is the last API Address you tried to use invalid?
store.selectIpfsProvider()
string
- Can bewindow.ipfs
,js-ipfs-api
orjs-ipfs
.
store.selectIpfsApiAddress()
string
- The API address of the IPFS instance.
store.doInitIpfs()
- Create a new IPFS instance. This will
window.ipfs
if you have IPFS Companion installed, or ajs-ipfs-http-client
instance otherwise.
store.doStopIpfs()
- Stops the IPFS instance. It is only intended to use with
js-ipfs
.
store.doUpdateIpfsApiAddress(address)
- Updates the API Address to
address
.
store.doDismissIpfsInvalidAddress()
- Dismisses the invalid address error.
Contribute
Feel free to dive in! Open an issue or submit PRs.
License
MIT © Protocol Labs