Sharing data between web browsers

Can data be shared directly between web browsers via IPFS?

Let’s say browser A reads data from disk via the File System API and adds it to IPFS with Helia. Some CIDs are created for the data files, and while I’m still trying to wrap my head around the possibility of decentralised discoverability, let’s maybe for now assume browser A publishes those CIDs to some centralised storage.

Browser B, also empowered by Helia, would like to access the data which browser A has added to IPFS. Assuming browser B has somehow obtained the CIDs, e.g. from the centralised storage, can it access the data from browser A, while it is open / online?

The Helia with React+Vite example is interesting, but I haven’t found an example of browser to browser communication.

Yes. If the browsers are behind NAT, there are some cases where NAT traversal with WebRTC fails, in which case it won’t work.

But generally this approach works:

See the following example: GitHub - ipfs-shipyard/ipfs-share-files: Share files directly from the browser using IPFS.

Deployed to:
https://share.ipfs.io/

That’s great, thanks!

I tried https://share.ipfs.io/ by sharing a small file in one browser (Chrome) on my desktop: after several minutes a sharing link appears, which I tried pasting to another browser on the same desktop (Firefox); after around five minutes a disabled Download button appears.

Currently I’m on a typical domestic Internet connection, which probably means I’m behind NAT?

Could this somehow be improved with a custom introducer / relay server?

It’s probably because it attempts to announce to the DHT, which takes time and is probably unnecessary since your multiaddrs for an ephemeral browser tab are very short lived.

We could improve it by embedding the multiaddr into the link and then optimistically connect to it on the other side.

1 Like