Top Related Projects
The JavaScript Implementation of libp2p networking stack.
An IPFS implementation in Go
An unobtrusive and user-friendly desktop application for IPFS on Windows, Mac and Linux.
Pinset orchestration for IPFS
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
- Creating an IPFS node:
import { create } from 'ipfs-core'
const node = await create()
console.log('IPFS node is ready')
- Adding content to IPFS:
const file = await node.add('Hello, IPFS!')
console.log('Added file:', file.path, file.cid.toString())
- 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)
- Pinning content:
await node.pin.add(file.cid)
console.log('File pinned successfully')
Getting Started
To get started with js-ipfs, follow these steps:
-
Install the package:
npm install ipfs-core
-
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()
-
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.
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
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 designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
âï¸ 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
The JavaScript implementation of the IPFS protocol
Getting started
- Read the docs
- Ensure CORS is correctly configured for use with the HTTP client
- Look into the examples to learn how to spawn an IPFS node in Node.js and in the Browser
- Consult the Core API docs to see what you can do with an IPFS node
- Head over to https://proto.school to take the IPFS course that covers core IPFS concepts and JS APIs
- Check out https://docs.ipfs.io for glossary, tips, how-tos and more
- Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io
- Find out about chat channels, the IPFS newsletter, the IPFS blog, and more in the IPFS community space.
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/interface-ipfs-core
Tests to ensure adherence of an implementation to the spec/packages/ipfs
An aggregator module that bundles the core implementation, the CLI, HTTP API server and daemon/packages/ipfs-cli
A CLI to the core implementation/packages/ipfs-core
The core implementation/packages/ipfs-core-types
Typescript definitions for the core API/packages/ipfs-core-utils
Helpers and utilities common to core and the HTTP RPC API client/packages/ipfs-daemon
Run js-IPFS as a background daemon/packages/ipfs-grpc-client
A gRPC client for js-IPFS/packages/ipfs-grpc-protocol
Shared module between the gRPC client and server/packages/ipfs-grpc-server
A gRPC-over-websockets server for js-IPFS/packages/ipfs-http-client
A client for the RPC-over-HTTP API presented by both js-ipfs and go-ipfs/packages/ipfs-http-server
JS implementation of the Kubo RPC HTTP API/packages/ipfs-http-gateway
JS implementation of the IPFS HTTP Gateway/packages/ipfs-http-response
Creates a HTTP response for a given IPFS Path/packages/ipfs-message-port-client
A client for the RPC-over-message-port API presented by js-ipfs running in a shared worker/packages/ipfs-message-port-protocol
Code shared by the message port client & server/packages/ipfs-message-port-server
The server that receives requests from ipfs-message-port-client
Packages
List of the main packages that make up the IPFS ecosystem.
This table is generated using the module
package-table
withpackage-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
Top Related Projects
The JavaScript Implementation of libp2p networking stack.
An IPFS implementation in Go
An unobtrusive and user-friendly desktop application for IPFS on Windows, Mac and Linux.
Pinset orchestration for IPFS
An IPFS implementation in Go
Browser extension that simplifies access to IPFS resources on the web
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot