Skip to content

ClojureScript Overviewλ︎

ClojureScript is an implementation of the Clojure programming language for the JavaScript platform (JavaScript browser engines and node.js)

The essentail differences between Clojure & ClojureScript are the host platform (Java or JavaScript) and the type of applications & services built with each language.

ClojureScript is predominately used for front-end applications, although can also be used as full stack solutions using a Clojure or node.js back-end server.

Minor Language differences

Due to differences between the Java and JavaScript host platforms, a small number of differences occur between Clojure and ClojureScript development.

ClojureScipt differences from Clojure

Code which is independent of host can be written in Clojure common files, i.e. *.cljc file name extension.

Learning ClojureSciptλ︎

Learning ClojureScript Section

Development Toolsλ︎

Clojure aware Editors also support ClojureScript. Use an editor most familiar with to minimise the initial learning curve.

Clojure aware editors have the same core functionality, so initial choice is not that important. As experience of ClojureScript grows, additional features can become valuable and a review of editor tooling can be done with more insight and understanding.

Build Toolsλ︎

ClojureScript is trans-piled (compiled) into JavaScript before running in a JavaScript browser engine or on node.js.

The main tools to support the ClojureScript workflow:

  • Figwheel - ClojureScript focused with the ability to bundle JavaScript npm packages (typically the simplest approach)
  • Shadow-cljs - implementation of ClojureScipt for node.js and therefore deeply integrated into the npm infrastructure (initially more complex but potential simpler when managing a significant amount of npm packages and dependencies)

Fighweelλ︎

figwheel logo name

Figwheel is a Clojure library used with Clojure CLI or Leiningen projects. ClojureScript applications can be built without writing JavaScript.

Figwheel can be 🌐 used with npm to include JavaScript packages. JavaScript bundle tools, e.g. 🌐 Webpack, are used to package up the ClojureScript app and npm packages for deployment.

Using NPM packages does add complexity to a ClojureScript project, although enables access to a large repository of libraries.

figwheel-template creates ClojureScript projects with figwheel configuration and optionally react, reagent, rum and bundle (webpack) options.

Figwheel Figwheel Template

Figwheel-main is library to use for Figwheel

Fighweel-main has replaced the figwheel library (now considered deprecated) and is a large rewrite of the tooling, providing a greatly enhanced experience.

Shadow-cljsλ︎

Shadow-cljs is installed via an npm package and designed to work directly with other node.js packages. Projects are created using npx create-cljs-project command.

Shadow-cljs requires node.js, npm (or yarn) and a Java host (Java SDK) and is written in a mixture of ClojureScript, JavaScript and Java.

Assumes that node.js is well understood and significant use of JavaScript npm packages will be used

Read the user guide in detail to avoid common issues when starting

Shadow-cljs User Guide

Common Librariesλ︎

As with any language, there are a wide range of choice for libraries to help build apps and many types of apps that can be built (UI / full-stacl / backend).

reagent is the most commonly used ClojureScript library for front-end apps, especially single page applications. reagent takes a react.js like approach.

re-frame builds upon reagent and supports the building of more complex UIs and stateful workflows.

reitit-frontend to define routing for URIs to support navigation within a ClojureScript app.

reagent reframe rum reitit-frontend