Search code examples
javascriptipfs

How to use IPFS from Javascript app without running ipfs node?


I have javascript app (ReactJs) which will run as an android hybrid app on mobile devices. I do not want to run full IPFS node on a mobile device, because it will consume a lot of its memory and energy. How can I connect my app to IPFS then?

I saw https://github.com/ipfs/js-ipfs-api#importing-the-module-and-usage, but it does not look usable for a mobile device again as it runs as a separated service.

Probably I have to connect to some IPFS node at the internet through IPFS API (https://ipfs.io/docs/api/), however is there a way to discover running nodes on the runtime and also to choose the fastest/closest one?


Solution

  • You have a couple of options here:

    • You can host an IPFS node in some cloud and have all your mobile devices connect to it
    • Run a js-ipfs node instance when you need it and garbage collect it afterward.

    Are you developing a PWA? js-ipfs works well on Chrome in Android phones, check https://github.com/ipfs/js-ipfs/tree/master/examples to learn how to get started.