Reagent is an awesome marriage of a React, an industry standard web front-end based on immutable component state, with ClojureScript, a functional lisp programming language with a terse syntax that heavily leverages immutable data. This post is about how to easily create a Reagent project that will get you up and running with familiar tooling similar to other React and NodeJs.
Leiningen Makes It Easy
In the NodeJs world you have build tools like webpack, gulp, and grunt. You have scaffolding utilities like yeoman, slush, or framework-specific cli's. You have a central registry of modules: npm. In the Clojure / ClojureScript world the command line utility lein pretty much does it all. You can install it pretty easily on most platforms by just downloading an installer file and clicking though it.
Scaffold a Figwheel Project With Reagent Plugin
The Leiningen (referred to as lein in the command line) function new is what I'm using here to create a new project. The figwheel project is a well-known Clojure boilerplate by Bruce Hauman for a nice coding experience where your front-end automatically updates in the browser without the need for a refresh, thus preserving app state. The next argument is the same of your project which I am naming "jims-fancy-example-project" in this case. By default this will create a folder with the name you enter, but I often like to add the flag "--to-dir ." to instead create the files in the current directory. Finally, we add the "-- --reagent" flag to use the reagent plugin which scaffolds our application as a reagent app. Here's the full command below.
The Awesomeness of ClojureScript
The posts on this site are written and maintained by Jim Lynch. About Jim...