PubSub in the browser with the JS IPFS HTTP API client

PubSub in the browser with the JS IPFS HTTP API client

EXCELLENT NEWS! You can now pubsub with the JS IPFS HTTP API client in the BROWSER!

Due to boring technical reasons (opens new window) it’s previously not been possible to support pubsub (opens new window) over the HTTP API (opens new window) in the browser. Now that the fetch API (opens new window) supports cancelation, and has done so for a while, pubsub support has arrived! Hooray \o/

There’s also a brand new example application that you can play with showing how to use pubsub in the browser: (opens new window)

Screenshot of PubSub in the browser example app

This was made possible by the experimentation done in a “lite” http client (opens new window) I was working on, which was originally meant to be just really really small (it’s currently ~13kb gzipped vs ~200kb for the regular client). To make it small we needed to switch to using the fetch API but I soon realized that this opened up a bunch of other opportunities, like enabling pubsub. We also get easily cancelable requests, request timeouts, custom fetch implementations and a switch to async/await and async iterators.

I originally demoed it in the lite client here:

Watch video (opens new window)

The lite client has been a great proving ground for ensuring the “hard parts” of the API are now possible using browser native APIs. I’ll be applying more of the learnings from there to the regular http client in the near future, which should hopefully result in a smaller bundle size, as well as more cool new features like this one.

Version 34 of ipfs-http-client is out now!

Thanks for reading 😘