Fork me on GitHub

Hi, are there any working examples that using reagent + server routing in one project? I am currently working for a project that needs API relay in the reagent project. If I do not do API relay, there is a CORS problem when using APIs from another domain. What is the recommended way to do this? Are there any working examples? Or should I create a Ring server in the same project to do API relay? Thanks.


@cmal: what do you mean by API relay? There are solutions for having ring and reagent in the same project and for separate projects and allowing CORS as well. Do you have a preference?


@shaun-mahood I have to request APIs from server side other than browser because of CORS. So I try to solve this problem by trying to add a routing server in my frontend project. The constraint here is that I can only maintain one project to do the job. Thanks.


@cmal: Ok, 2 options you could check out are Luminus ( ) and chestnut ( ) - both have front end and back end in a singlw project. I think you can also do it with a new reagent template ( ).


@shaun-mahood Thanks. I will dive into chestnut for some ideas. I currently use re-frame in the frontend project and try to connect to a mongo db backend server and/or its APIs.


The reagent-template is also a great idea. I'll try to learn something from this.


Hi, folks. A beginner here. I was trying to whip together a simple proof of concept of server rendered reagent. I had started with an actual clojure app, using http-kit, with the intention of using reagent's server utils (`render-to-string`). I quickly realized that reagent is clojurescript (duh) and cannot be used via clojure directly.


Since these server util functions are clojurescript, does this mean there's an approach to running clojurescript on the server? Or can reagent work with clojure? I saw the cookbook, using nashorn, but if that's what it takes I think I may just prefer to stick with my current node version of this project.


My clojure demo is like a basic 10 liner. Is there something comparable in clojurescript?


@ryancole You can use server-side render-to-string with clojurescript on node. See:


@terje OK, that's kind of where I was heading next. So, now I'd no longer be running a JVM Clojure, on the server, I'd be running Node ClojureScript, correct? Which means my dependencies would no longer be Clojure (JVM) they'd be from the NPM world (JS)?


I'd be essentially writing a Node app, but using a CLJS compiler. Correct?


(similar to perhaps coffeescript, typescript, etc)


Right. If you still need Clojure/JVM functionality consider an architecture with a cljs/node front-end server and a clojure/jvm back-end server.


Issue is that one little requirement of performing server rendering of React. 😕


I'm not against CLJS on server. The current implement of this application I'm contemplating converting to Clojure is in plain node.


I'd be familiar with the modules, etc. I can just already imagine issues where interop is kind of wonky, or there lacks CLJS wrappers, etc.


I havent played with this yet, but seems possibly relevant:


A benefit of using cljs on node is better ability to share code between browser app and server.


Yea, I totally agree there. I'm just wondering if there's an annoyance of having to locate wrappers for various javascript modules, etc.


Or use the interop, which might have conflicting usage patterns, etc.


I don't know. I'll just have to find out. 🙂


@ryancole I'm finding interop is usually not too hard to wrap up, and I'm hoping to get some official wrappers for stuff like db drivers


most of the core stuff is cljs though, I'm using mount for state, but you could use component as well, bidi for routing, and timbre for logging


most of ring core and the middleware has been ported over now as well


the template even sets up a test harness now out of the box


that said it is all very new, so there are bugs and rough edges 🙂