A full P2P protocol written entirely in JavaScript

A P2P JavaScript protocol

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.js, opening the door to a world of possibilities.

Disable Animation
The js-ipfs library is in Alpha state.The codebase hasn't been audited by security specialists and it shouldn't be used to store, share or publish sensitive information.

Features

Packed with all the things you know and love about IPFS. This implementation also carries some extra neat things that are unique to the Browser. It's the toolkit to power all your DWeb Applications.

Run on Node.js and the Browser

js-ipfs works out of the box on Node.js, Electron and any modern browser. It is also customizable by design so that you can use it on your favorite runtime.

Implements the full IPFS Stack

No feature was left behind. js-ipfs is not a light client, it is the full implementation of the IPFS protocol.

Use PubSub to communicate in realtime with the other peers

IPFS nodes can create network topologies based on topics of interest to broadcast events in realtime.

Add and retrieve files from anywhere in the IPFS Network

IPFS is designed to use the power of Content Addressing to find the nodes in the network that have the content you are looking for. In the same way, you can add data and other nodes will find it too.

Use the DAG API to traverse over any hash linked data structure

IPFS uses IPLD, the InterPlanetary Linked-Data, a model that enables you interact with data from multiple sources, such as git, blockchains and more.

libp2p is built in

libp2p is the Modular Networking Stack that was created for IPFS and now you can use it through IPFS for your application directly as well.

Run it as a daemon

js-ipfs also comes with the option to run it as a daemon so that you can interact with it using the HTTP API that you are familiar with from go-ipfs.

Create stable addresses for changing data

It comes with IPNS, the Interplanetary Naming System, a way to author mutable pointers (records) to distribute updates in an authenticated and certified way.

Getting Started

IPFS gives you a Content Addressing primitive for all your data on the DWeb. You can make data available to the network or fetch existing data through its CID, the Content Identifier. Try it out below!

Adding data to IPFS

const node = new IPFS()

const data = 'Hello, <YOUR NAME HERE>'

// once the node is ready
node.once('ready', () => {
  // convert your data to a Buffer and add it to IPFS
  node.files.add(node.types.Buffer.from(data), (err, files) => {
    if (err) return console.error(err)

    // 'hash', known as CID, is a string uniquely addressing the data
    // and can be used to get it again. 'files' is an array because
    // 'add' supports multiple additions, but we only added one entry
    console.log(files[0].hash)
  })
})

Output

Getting data from IPFS

Using Javascript in the Browser or Node.js

const node = new IPFS()

node.once('ready', () => {
  node.files.cat('QmPChd2hVbrJ6bfo3WBcTW4iZnpHm8TEzWkLHmLpXhF68A', (err, data) => {
    if (err) return console.error(err)

    // convert Buffer back to string
    console.log(data.toString())
  })
})

Output

Using the CLI

npm install ipfs -g
jsipfs cat QmPChd2hVbrJ6bfo3WBcTW4iZnpHm8TEzWkLHmLpXhF68A

Using the HTTP Gateway

https://ipfs.io/ipfs/QmPChd2hVbrJ6bfo3WBcTW4iZnpHm8TEzWkLHmLpXhF68A
Learn More

Service Worker Gateway

Turn this page into a full IPFS Gateway without touching any servers or using HTTP to fetch content from the IPFS Network! Yes, you read it right, the Service Worker Gateway with js-ipfs can connect directly to the IPFS Network.

Enable Service Worker

What people are building with it

Paratii builds open source technology for video streaming and curation, with js-ipfs and Ethereum contracts. The Portal is a web app with curated crypto-related videos that runs on IPFS.

Project Preview

Publications & Talks

Watch project updates, demos and other talks by the IPFS Community on the JavaScript project of IPFS. We will be adding dozens more talks soon from the IPFS Dev Meetings.

IPFS on the Brave Browser, Alan Shaw

CRDTs as the foundation for Distributed Web Apps, Pedro Teixeira

A Regular JS Core Dev Call, join us!

Community

js-ipfs is an MIT Licensed, Open Source project from the IPFS community. There are many ways you can contribute: help write the specification, code implementations and tools using libp2p, craft examples and tutorials, and join our regular product calls to discuss libp2p with us.