Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 326
user3024710 Avatar asked Jul 29 '17 10:07

user3024710


People also ask

Does IPFS support JavaScript?

js-ipfs paves the way for the Browser implementation of the IPFS protocol. Written entirely in JavaScript, it runs in a Browser, a Service Worker, a Web Extension and Node. js, opening the door to a world of possibilities. js-ipfs runs in a Browser, a Service Worker, a Web Extension and Node.

How do I open IPFS links?

Alternatively, you can access IPFS content from any browser by using a public gateway such as https://ipfs.io or https://cloudflare-ipfs.com. A gateway will automatically route you to IPFS content using the link, and there's a long list of alternative gateways available.


1 Answers

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.

like image 174
David Dias Avatar answered Sep 28 '22 06:09

David Dias