Convert Figma logo to code with AI

ipfs logojs-ipfs

IPFS implementation in JavaScript

7,432
1,246
7,432
0

Top Related Projects

The JavaScript Implementation of libp2p networking stack.

16,006

An IPFS implementation in Go

An unobtrusive and user-friendly desktop application for IPFS on Windows, Mac and Linux.

Pinset orchestration for IPFS

16,006

An IPFS implementation in Go

Browser extension that simplifies access to IPFS resources on the web

Quick Overview

js-ipfs is a JavaScript implementation of the IPFS (InterPlanetary File System) protocol. It allows developers to run IPFS nodes in JavaScript environments, including browsers and Node.js, enabling decentralized file storage and sharing capabilities in web applications.

Pros

  • Cross-platform compatibility (works in browsers and Node.js)
  • Easy integration with existing JavaScript projects
  • Supports both IPFS and IPLD (InterPlanetary Linked Data)
  • Active development and community support

Cons

  • Performance may be slower compared to Go-IPFS implementation
  • Limited support for some advanced IPFS features
  • Potential security concerns when running in browser environments
  • Requires careful management of resources in long-running applications

Code Examples

  1. Creating an IPFS node:
import { create } from 'ipfs-core'

const node = await create()
console.log('IPFS node is ready')
  1. Adding content to IPFS:
const file = await node.add('Hello, IPFS!')
console.log('Added file:', file.path, file.cid.toString())
  1. Retrieving content from IPFS:
const stream = node.cat(file.cid)
let data = ''
for await (const chunk of stream) {
  data += chunk.toString()
}
console.log('Retrieved data:', data)
  1. Pinning content:
await node.pin.add(file.cid)
console.log('File pinned successfully')

Getting Started

To get started with js-ipfs, follow these steps:

  1. Install the package:

    npm install ipfs-core
    
  2. Create a new JavaScript file (e.g., ipfs-example.js) and add the following code:

    import { create } from 'ipfs-core'
    
    async function main() {
      const node = await create()
      console.log('IPFS node is ready')
    
      const file = await node.add('Hello, IPFS!')
      console.log('Added file:', file.path, file.cid.toString())
    
      const stream = node.cat(file.cid)
      let data = ''
      for await (const chunk of stream) {
        data += chunk.toString()
      }
      console.log('Retrieved data:', data)
    
      await node.stop()
    }
    
    main()
    
  3. Run the example:

    node ipfs-example.js
    

This will create an IPFS node, add content, retrieve it, and then stop the node.

Competitor Comparisons

The JavaScript Implementation of libp2p networking stack.

Pros of js-libp2p

  • More focused and modular, allowing for greater flexibility in network stack composition
  • Can be used independently of IPFS for other peer-to-peer applications
  • Lighter weight and potentially more performant for specific use cases

Cons of js-libp2p

  • Requires more configuration and setup compared to the all-in-one js-ipfs solution
  • May lack some IPFS-specific features and optimizations out of the box
  • Steeper learning curve for developers new to peer-to-peer networking concepts

Code Comparison

js-ipfs:

import IPFS from 'ipfs-core'

const ipfs = await IPFS.create()
const cid = await ipfs.add('Hello, IPFS!')
console.log(cid.toString())

js-libp2p:

import Libp2p from 'libp2p'
import TCP from 'libp2p-tcp'
import { NOISE } from '@chainsafe/libp2p-noise'
import MPLEX from 'libp2p-mplex'

const node = await Libp2p.create({
  transports: [TCP()],
  connectionEncryption: [NOISE],
  streamMuxers: [MPLEX]
})
await node.start()

This comparison highlights the main differences between js-ipfs and js-libp2p, showcasing js-libp2p's modularity and flexibility, while also noting its increased complexity compared to the more integrated js-ipfs solution.

16,006

An IPFS implementation in Go

Pros of kubo

  • Written in Go, offering better performance and resource efficiency
  • More mature and feature-complete implementation of IPFS
  • Supports a wider range of IPFS features and protocols

Cons of kubo

  • Larger binary size and more complex setup compared to js-ipfs
  • Less suitable for browser-based or JavaScript-centric environments
  • Steeper learning curve for developers primarily familiar with JavaScript

Code comparison

kubo (Go):

node, err := core.NewNode(ctx, &core.BuildCfg{
    Online: true,
    Routing: libp2p.DHTOption,
})
if err != nil {
    return err
}

js-ipfs (JavaScript):

const node = await IPFS.create({
  repo: 'ok' + Math.random(),
  config: { Bootstrap: [] }
})

Summary

kubo is a more robust and performant IPFS implementation, ideal for server-side and production environments. js-ipfs offers easier integration with JavaScript projects and browser compatibility, making it suitable for web applications and JavaScript-based systems. The choice between the two depends on the specific use case, performance requirements, and development ecosystem.

An unobtrusive and user-friendly desktop application for IPFS on Windows, Mac and Linux.

Pros of ipfs-desktop

  • User-friendly GUI for easy IPFS interaction
  • Cross-platform desktop application (Windows, macOS, Linux)
  • Integrates with system tray for quick access and file sharing

Cons of ipfs-desktop

  • Limited to desktop environments, not suitable for server-side or mobile use
  • May consume more system resources compared to a lightweight JS implementation
  • Less flexible for custom integrations or programmatic usage

Code Comparison

js-ipfs:

import { create } from 'ipfs-core'

const ipfs = await create()
const { cid } = await ipfs.add('Hello world')
console.log(cid.toString())

ipfs-desktop:

// No direct code comparison available as ipfs-desktop is a GUI application
// Interaction is primarily through the user interface

Summary

js-ipfs is a JavaScript implementation of IPFS, offering flexibility for developers to integrate IPFS functionality into various applications and environments. It's lightweight and can be used in both browser and Node.js contexts.

ipfs-desktop provides a user-friendly desktop application for interacting with IPFS, making it accessible to non-technical users. It offers system-level integration but is limited to desktop platforms and may not be suitable for programmatic or server-side use cases.

Choose js-ipfs for development flexibility and lightweight integration, or ipfs-desktop for a ready-to-use GUI application with desktop system integration.

Pinset orchestration for IPFS

Pros of ipfs-cluster

  • Designed for coordinating and managing multiple IPFS nodes in a cluster
  • Provides advanced pinning and replication features across nodes
  • Offers a REST API for cluster management and monitoring

Cons of ipfs-cluster

  • More complex setup and configuration compared to js-ipfs
  • Requires additional resources to run alongside IPFS nodes
  • May have a steeper learning curve for beginners

Code Comparison

ipfs-cluster (Go):

import (
    "github.com/ipfs/ipfs-cluster/api"
    "github.com/ipfs/ipfs-cluster/api/rest/client"
)

cfg := &client.Config{
    Host: "/ip4/127.0.0.1/tcp/9094",
}
c, _ := client.NewDefaultClient(cfg)

js-ipfs (JavaScript):

import { create } from 'ipfs-core'

const ipfs = await create()
const { cid } = await ipfs.add('Hello world')
console.log(cid.toString())

Key Differences

  • ipfs-cluster focuses on cluster management, while js-ipfs is a JavaScript implementation of IPFS
  • ipfs-cluster is written in Go, whereas js-ipfs is in JavaScript
  • js-ipfs is more suitable for browser and Node.js environments, while ipfs-cluster is designed for server-side deployments
  • ipfs-cluster provides advanced features for distributed pinning and replication, which are not available in js-ipfs
16,006

An IPFS implementation in Go

Pros of kubo

  • Written in Go, offering better performance and resource efficiency
  • More mature and feature-complete implementation of IPFS
  • Supports a wider range of IPFS features and protocols

Cons of kubo

  • Larger binary size and more complex setup compared to js-ipfs
  • Less suitable for browser-based or JavaScript-centric environments
  • Steeper learning curve for developers primarily familiar with JavaScript

Code comparison

kubo (Go):

node, err := core.NewNode(ctx, &core.BuildCfg{
    Online: true,
    Routing: libp2p.DHTOption,
})
if err != nil {
    return err
}

js-ipfs (JavaScript):

const node = await IPFS.create({
  repo: 'ok' + Math.random(),
  config: { Bootstrap: [] }
})

Summary

kubo is a more robust and performant IPFS implementation, ideal for server-side and production environments. js-ipfs offers easier integration with JavaScript projects and browser compatibility, making it suitable for web applications and JavaScript-based systems. The choice between the two depends on the specific use case, performance requirements, and development ecosystem.

Browser extension that simplifies access to IPFS resources on the web

Pros of ipfs-companion

  • Browser integration: Seamlessly integrates IPFS functionality into web browsers
  • User-friendly interface: Provides a graphical interface for interacting with IPFS
  • Enhanced privacy: Offers features like automatic redirection to IPFS content

Cons of ipfs-companion

  • Limited functionality: Focuses on browser-specific features, less versatile than js-ipfs
  • Dependency on browser: Requires a supported web browser to function

Code comparison

js-ipfs:

import { create } from 'ipfs-core'

const ipfs = await create()
const { cid } = await ipfs.add('Hello world')
console.log(cid.toString())

ipfs-companion:

// No direct code equivalent, as ipfs-companion is a browser extension
// Interaction is primarily through the browser interface

Summary

js-ipfs is a full JavaScript implementation of IPFS, offering a wide range of functionality for building IPFS-powered applications. It's versatile and can be used in various JavaScript environments.

ipfs-companion is a browser extension that brings IPFS capabilities to web browsers, providing a user-friendly interface for interacting with the IPFS network. It's more focused on enhancing the browsing experience with IPFS integration.

Choose js-ipfs for building custom IPFS applications, and ipfs-companion for easy browser integration and user-friendly IPFS interactions.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

⛔️ DEPRECATED: js-IPFS has been superseded by Helia

📚 Learn more about this deprecation or how to migrate

⚠️ If you continue using this repo, please note that security fixes will not be provided

IPFS in JavaScript logo

The JavaScript implementation of the IPFS protocol


Getting started

Table of Contents

Getting Started

Install as a CLI user

Installing ipfs globally will give you the jsipfs command which you can use to start a daemon running:

$ npm install -g ipfs
$ jsipfs daemon
Initializing IPFS daemon...
js-ipfs version: x.x.x
System version: x64/darwin
Node.js version: x.x.x
Swarm listening on /ip4/127.0
.... more output

You can then add a file:

$ jsipfs add ./hello-world.txt
added QmXXY5ZxbtuYj6DnfApLiGstzPN7fvSyigrRee3hDWPCaf hello-world.txt

Install as an application developer

If you do not need to run a command line daemon, use the ipfs-core package - it has all the features of ipfs but in a lighter package:

$ npm install ipfs-core

Then start a node in your app:

import * as IPFS from 'ipfs-core'

const ipfs = await IPFS.create()
const { cid } = await ipfs.add('Hello world')
console.info(cid)
// QmXXY5ZxbtuYj6DnfApLiGstzPN7fvSyigrRee3hDWPCaf

Documentation

Structure

This project is broken into several modules, their purposes are:

Packages

List of the main packages that make up the IPFS ecosystem.

PackageVersionDepsCI/TravisCoverageLead Maintainer
Files
ipfs-unixfsnpmDepsTravis CIcodecovAlex Potsides
Repo
ipfs-reponpmDepsTravis CIcodecovAlex Potsides
ipfs-repo-migrationsnpmDepsTravis CIcodecovN/A
Exchange
ipfs-bitswapnpmDepsTravis CIcodecovDirk McCormick
IPNS
ipnsnpmDepsTravis CIcodecovVasco Santos
Generics/Utils
ipfs-utilsnpmDepsTravis CIcodecovHugo Dias
ipfs-http-clientnpmDepsTravis CIcodecovAlex Potsides
ipfs-http-responsenpmDepsTravis CIcodecovVasco Santos
ipfsd-ctlnpmDepsTravis CIcodecovHugo Dias
is-ipfsnpmDepsTravis CIcodecovMarcin Rataj
aegirnpmDepsTravis CIcodecovHugo Dias
libp2p
libp2pnpmDepsTravis CIcodecovJacob Heun
peer-idnpmDepsTravis CIcodecovVasco Santos
libp2p-cryptonpmDepsTravis CIcodecovJacob Heun
libp2p-floodsubnpmDepsTravis CIcodecovVasco Santos
libp2p-gossipsubnpmDepsTravis CIcodecovCayman Nava
libp2p-kad-dhtnpmDepsTravis CIcodecovVasco Santos
libp2p-mdnsnpmDepsTravis CIcodecovJacob Heun
libp2p-bootstrapnpmDepsTravis CIcodecovVasco Santos
@chainsafe/libp2p-noisenpmDepsTravis CIcodecovN/A
libp2p-tcpnpmDepsTravis CIcodecovJacob Heun
libp2p-webrtc-starnpmDepsTravis CIcodecovVasco Santos
libp2p-websocketsnpmDepsTravis CIcodecovJacob Heun
libp2p-mplexnpmDepsTravis CIcodecovVasco Santos
libp2p-delegated-content-routingnpmDepsTravis CIcodecovJacob Heun
libp2p-delegated-peer-routingnpmDepsTravis CIcodecovJacob Heun
IPLD
@ipld/dag-pbnpmDepsTravis CIcodecovN/A
@ipld/dag-cbornpmDepsTravis CIcodecovN/A
Multiformats
multiformatsnpmDepsTravis CIcodecovN/A
mafmtnpmDepsTravis CIcodecovVasco Santos
multiaddrnpmDepsTravis CIcodecovJacob Heun

This table is generated using the module package-table with package-table --data=package-list.json.

Want to hack on IPFS?

The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out:

Read the Code of Conduct and JavaScript Contributing Guidelines.

  • Check out existing issues The issue list has many that are marked as 'help wanted' or 'difficulty:easy' which make great starting points for development, many of which can be tackled with no prior IPFS knowledge
  • Look at the IPFS Roadmap This are the high priority items being worked on right now
  • Perform code reviews More eyes will help a. speed the project along b. ensure quality, and c. reduce possible future bugs.
  • Add tests. There can never be enough tests.

License

FOSSA Status

NPM DownloadsLast 30 Days