Just some experiments with rendering clojurescript server side
From here: https://github.com/reagent-project/reagent-cookbook
curl http://localhost:3000/server-data
in a shell, receive a completely server rendered pageVersion 1: Run with figwheel for REPL + Hot Module reloading. In 3 separate terminal windows
# start the server side JS build
$ lein cljsbuild auto server-side
# serve the ring handler + static files
$ lein ring server-headless
# start repl, HMR + auto rebuild
$ lein figwheel hmr
Version 2: Run without watching and hot module reload, in production* mode
# build cljs
$ lein cljsbuild once prod server-side
# start ring server, tell it to use prod js
$ PROD=true lein ring server-headless
* = this setup is in no way production ready
main
, for client side app init, and render-page
that is used by the server side rendererRoutes are only defined in CLJS, in reagent-server-rendering.core there's a pages
map that looks like this:
(def pages
{"home" pages/home-page
"about" pages/about-page
"compare-argv" pages/argv-page
"server-data" pages/server-data
"autocomplete" pages/auto-page
"404" pages/not-found })
the string key becomes the URL, the value is a reagent component