Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

Latest commit

History

History
24 lines (15 loc) 路 2.37 KB

overview.md

File metadata and controls

24 lines (15 loc) 路 2.37 KB
title menu
Working with IPFS in JS
reference
parent weight
js_implementation
1

There are two main JavaScript libraries for working with IPFS. Both work in Node.js and in modern web browsers:

  • js-ipfs is a full implementation of IPFS, similar to go-ipfs. You can use it either as a command-line application or as a library to start an IPFS node directly in your program.

  • js-ipfs-api is a smaller library that controls an IPFS node that is already running via its HTTP API. js-ipfs actually uses this library internally if it detects that another node is already running on your computer. You can also interact with the HTTP API directly using fetch() in a browser or a module like request in Node.js, but using this library can be much more convenient.

Both libraries have the same interface for using all the major IPFS commands.

Whenever reasonable, we recommend the second method (interacting with a separate IPFS node via the HTTP API). Keeping the IPFS node in a separate process (even if it鈥檚 one your program spawns) isolates you from any stability problems with the node. If a user already has IPFS installed, this also means you can take advantage of a single, common installation on their computer. It鈥檚 also less code to load in a browser. If you need to spawn a separate IPFS process, you might want to take a look at js-ipfsd-ctl, which uses the same interface to spawn a go-ipfs node, a js-ipfs node, or an in-process js-ipfs node.

IPFS in Web Browsers

Both the js-ipfs and js-ipfs-api libraries work in browsers, but each has some special considerations noted in their READMEs.

We are also building a browser extension named IPFS Companion. If a visitor to your site has it installed, it will make a global window.ipfs object available to your JavaScript. This object has the same interface as js-ipfs-api, but comes with much better security controls and lets you use IPFS without loading any special libraries.