This was an experiment to see how plausible it would be to pre-render React.js components using Clojure and Java 8's Nashorn JavaScript engine.
Using the linked resources, it was no trouble getting this trivial example up and running.
I was expecting the Java/Nashorn interop to be verbose and involve lots of
boilerplate, but with the help of a few utility functions I was able to build
up a nice API. (e.g. (react-render (sample-react-component data))
)
I'm anxiously awaiting the opportunity to use this stack in a non-trivial application. I would recommend others give Clojure/Nashorn some thought before defaulting to (node|io).js for their next SPA that requires server-side rendering (Sorry, but I'm not bringing category theory into this conversation.)
You'll want to have a look at renderer.clj.
You will need Leiningen 2.0.0 or above installed.
To start a web server for the application, run:
lein ring server
lein with-profile test midje