Fork me on GitHub

What's a good clojurescript library to handle a SSE response (Server-Sent Events) [editted]? I found some old libs (chord) and the main one cljs-http doesn't seem to handle the body in an async way


technically it's Server-Sent Events


it should be just a regular http request that is reading from the connection until it's closed, and after that it starts again.


a yeah typed too quickly lol. I know it's very "simple", with curl for instance. But cljs-http doesn't allow me to do it (I think). Do you have a specific library or everything hand-rolled?


I use websockets for this type of server push.


@U1QQJJK89 Any specific library to use with websockets (client side)?


I feel we have a gap for a proper http library. Especially one that has one interface over all the different platforms that clojure now is targetting


Nothing client side. Im using immutant server side. Then just js interop client side. some core.async. transit encoding with LZString compression.


multimethods for message routing on top of the websockets


what I have found amazing is websockets + transit + multimethods + cljc as a gamechanger (IMHO). Being able to write client/server messaging "workflows" in a single cljc file with automatic dispatch (via multimehtods) feels pretty liberating.


Yeah exactly, I want that too. And the core of clojure works great on several platforms. It's the edges where you find yourself lost. E.g. now I want to do http requests. I have something for this that works on the server side, but when I think hey let's do this in a GraalVM environment or nodejs, or browser, they will all have a different implementation. If we can fix that .. 🙂


@U0FT7SRLP for websockets I recommend sente (handles client and server with reconnects and downgrades to ajax) -

👍 8
❤️ 4

You should definitely take a look at Hanasu It is a lot simpler than Sente but is very flexible.

👍 4
👁️ 4

It seems most people are more into websockets


Yes, generally I now use them for all this client/server (and/or peer to peer) communication. For the most part it is simpler, more flexible, and just works. For example, I use Hanasu extensively in several projects and I know some others do as well. I use it for python communication as well


Do you have an example clj/cljs/cljc project written in Hanasu one could examine?


several. Aerobio (which also uses pyhansu), Hanami and Saite are the public available ones:,,


There are some others that I need/should release. These are not so much "written in Hanasu" as "written with Hanasu as the msg service"


I hope that a part of my issues with CLJS clients will be tackled by the new ring spec (see my point in this thread


Where do beginners clojurescript questions belong? Because the following question will show I'm a total beginner in both clojurescript and web dev in general I'm afraid 😄. I trained a machine learning model in clojure and now I would like to use it in a small interactive webpage. I dived into using clojurescript for this, without really thinking much of exactly how I would communicate between my webapp and the model. The input for the model is a simple clojure vector, the output a single number. What would be the best way to this input-output communication going between clojurescript and clojure?


It's either here or in #beginners


As to your actual question, it seems like a plain AJAX request is more than enough.


Thanks for the quick answer! 🙂 I'll look into AJAX requests, a quick search suggests to use cljs-http, is that still the standard/easiest way?


Yeah, the library is still widely used, you should be fine with it.


Great thanks! A last, very beginner question, is it ok to use the same base url (with different routing ofc) for both my clojurescript app and for my clojure "api"?

Robin Jakobsson13:02:34

Yes, that should work.


I’m trying to make a router work with an re-frame application, but I’m not sure yet how do I make something like react-router with clojurescript, anyone that can help with? I tried to use secretary and now I’ve changed to re-frame-routing that uses bidi and pushy under the hood, but I still couldn’t make it work


I'm using kee-frame with bidi, it works perfectly. What do you mean by "couldn't make it work", what were the exact issues?


I have used secretary without problems. What does react-router do differently?


The problem is that I couldn’t sync secretary’s dispatch! with browser’s url, I was able to route the application internally but the route doesn’t reflect on the browser URL, and if I try to change the URL manually (like a href’s link) the page reloads


I've recently had the same question for secretary. Take a look at accountant which works together with secretary to take care of the browser history, it will update the browser, too.