Home

Awesome

⛔️ 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.

Build Status

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:

Usage

Add ipfs-redux-bundle to your store

bundles/index.js

import { composeBundles } from 'redux-bundler'
import ipfsBundle from 'ipfs-redux-bundle'
// ... import other bundles

export default composeBundles(
  ipfsBundle({
    // These are the defaults:
    tryCompanion: true,   // set false to bypass ipfs-companion verification
    tryWindow: true,      // set false to bypass window.ipfs verification
    tryApi: true,         // set false to bypass js-ipfs-http-client verification. Uses data from ipfsApi variable in localStorage
    tryJsIpfs: false,     // set true to attempt js-ipfs initialisation.
    getJsIpfs: null       // must be set to a js-ipfs instance if tryJsIpfs is true.
  })
  // ... 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

import React, { Component } from 'react'
import { connect } from 'redux-bundler-react'

export class App extends Component {
  componentDidMount () {
    this.props.doInitIpfs()
  }
  render () {
    // ipfs-css powered gorgeous ui here.
  }
}

export default connect(
  'doInitIpfs',
  App
)

Enable js-ipfs

To enable js-ipfs, intialise the bundle with the following opts

  ipfsBundle({
    tryJsIpfs: true,
    getJsIpfs: () => import('ipfs')
  })

API

Adds the following methods to the redux store.

store.selectIpfsReady()

store.selectIpfsInitFailed()

store.selectIpfsInvalidAddress()

store.selectIpfsProvider()

store.selectIpfsApiAddress()

store.doInitIpfs()

store.doStopIpfs()

store.doUpdateIpfsApiAddress(address)

store.doDismissIpfsInvalidAddress()

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Protocol Labs