This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add document for running JS IPFS in the browser #2392
Merged
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
50ab2c2
Add document for running JS IPFS in the browser
tapaswenipathak 60756b7
dht information line fixes
tapaswenipathak f4abde3
remove whitespaces
tapaswenipathak 7ae4d96
js-ipfs introductory line fixes
tapaswenipathak 42b41fd
i don't remember now
tapaswenipathak 579f01d
separate tcp and delegated routing?
tapaswenipathak ba21205
Update doc/using-js-ipfs-in-the-browser.md
tapaswenipathak 7dc4524
Update doc/using-js-ipfs-in-the-browser.md
tapaswenipathak 3bbed60
Update doc/using-js-ipfs-in-the-browser.md
tapaswenipathak 4e9b016
line item fixes
tapaswenipathak 8035860
Merge branch 'ticket-2231' of github.com:tapaswenipathak/js-ipfs into…
tapaswenipathak 873d147
english grammer fixes
tapaswenipathak 0251e14
Update doc/using-js-ipfs-in-the-browser.md
tapaswenipathak 8216eaa
Update doc/using-js-ipfs-in-the-browser.md
tapaswenipathak 141127a
add example
tapaswenipathak 015ea67
revert per the initial statement
tapaswenipathak 1929d46
technical behavioral line item fixes
tapaswenipathak 62e38c9
fix few more statements
tapaswenipathak df1e5b0
Merge branch 'ticket-2231' of github.com:tapaswenipathak/js-ipfs into…
tapaswenipathak 256d900
Update using-js-ipfs-in-the-browser.md
lidel b603f18
Update using-js-ipfs-in-the-browser.md
lidel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
Using JS IPFS in The Browser | ||
---------------------------- | ||
|
||
The document describes how you can use JS IPFS in the browser. JS IPFS is the | ||
implementation of the IPFS protocal for browser. JS IPFS runs in a browser as a | ||
service worked, a web extenstion and node.js. The document describes how you can | ||
boost the speed and reduce the errors you face often because of limitation of | ||
js-ipfs. | ||
|
||
There are few different components for implementing JS IPFS in the browser. These | ||
tapaswenipathak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
are webrtc and websocket-star which will make it easier for implemented JS IPFS | ||
tapaswenipathak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
in the browser and boost the speed and reduce the errors. | ||
|
||
You can find the information present for enabling webRTC support for js-ipfs in | ||
the browser [here](https://github.com/ipfs/js-ipfs#how-to-enable-webrtc-support-for-js-ipfs-in-the-browser) and a different one is | ||
implementing with webrtc-star, you can find information [here](https://github.com/ipfs/js-ipfs#is-there-a-more-stable-alternative-to-webrtc-star-that-offers-a-similar-functionality). | ||
tapaswenipathak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
You can find information about running IPFS in the broswer [here](https://github.com/ipfs/js-ipfs#table-of-contents). | ||
tapaswenipathak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Getting Data From IPFS | ||
----------------------- | ||
|
||
Using Javascript in the browser | ||
|
||
```js | ||
const node = new IPFS() | ||
|
||
node.once('ready', () => { | ||
node.pipe('QmPChd2hVbrJ6bfo3WBcTW4iZnpHm8TEzWkLHmLpXhF68A', (err, data) => { | ||
if (err) return console.error(err) | ||
|
||
// convert Buffer back to string | ||
console.log(data.toString()) | ||
}) | ||
}) | ||
``` | ||
tapaswenipathak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
JS IPFS Restriction in Web Browser | ||
------------------------------------------ | ||
|
||
- There is no DHT in js-ipfs. | ||
tapaswenipathak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
In browser a JS IPFS node is more restricted because of the same origin policy | ||
that decrease the discover/connect with peers, external peers without rendezvous | ||
and relay servers, delegating peer/content routing and preload servers for content | ||
discoverablilty hard and erroneous even with swarm peers. | ||
tapaswenipathak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- Unable in opening TCP connections even if one sets up delegating routing the | ||
issue will persist for connecting most of peers in the swarm as described a | ||
little above. | ||
tapaswenipathak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- Connection with websocket ports should be adhering with [secure contexts](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts) limitations. | ||
|
||
JS IPFS Best Practices | ||
---------------------- | ||
|
||
- Run in fedrated model. | ||
tapaswenipathak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Configure nodes for using webrtc or websocket-star. | ||
- Run independant instance as default one are under high load and YMMV. | ||
tapaswenipathak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Make sure content you are implementing is cached in go-ipfs | ||
- manually `pin` or preload CIDs of interest with `refs -r` beforehand. | ||
- preload content on the fly using [preload](https://github.com/ipfs/js-ipfs#optionspreload) or | ||
configuring [delgated routing](https://github.com/ipfs/js-ipfs#configuring-delegate-routers). | ||
tapaswenipathak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Here you will be using go-ipfs's API + nginx. | ||
|
||
JS IPFS Examples | ||
---------------- | ||
|
||
We have documented a lot of examples for implemented JS IPFS in the browser, you | ||
can find them [here](https://github.com/ipfs/js-ipfs-http-client/tree/master/examples). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.