Clojure libraries I recommend

Brown maple leafs on the ground.

Every now and then I see people asking what Clojure and ClojureScript libraries they should be using. In this post, I’ll share my list of libraries for building full-stack Clojure/ClojureScript web applications. I’ve been building this kind of applications for a while now and I believe you can rely on these libraries.

Here’s what I’m looking for:

  • Robustness. I don’t want to debug buggy libraries – I write enough bugs of my own.
  • Extensiblity. With a long-lived application, you’ll end up wanting all kind custom things that the library authors didn’t anticipate. Data-driven design helps here.
  • Implemetation is easy to understand. Eventually I’ll read the source anyway. Either there is a bug or there is no documentation.

This list is not meant as the final truth: there are plenty of good libraries out there and you might choose different ones based on your needs and preferences. There’s an obvious bias, too: many of these libraries were made by my colleagues at Metosin.

Clojure backend

Framework. I appreciate the data-driven nature of Integrant. Combine it with Integrant-REPL for reloaded workflow.

JDBC database connection pool. I’ve never had any problems with HikariCP and it’s easy to configure and instrument. hikari-cp is a handy Clojure wrapper.

Configuration. I use Maailma and I’ve written about how to use it. cprop is very similar and probably a bit more powerful.

HTTP routing. I like the data-driven nature of reitit. It’s fast, too, and has enough extension points so that anything you want is possible. I would not use compojure-api because the implementation is way too hard to understand.

Logging. I use Timbre because it’s so easy to write custom appenders for it. Admittedly I haven’t checked out the popular Java options.

Test runner. Eftest is the test runner of my dreams and you can’t go wrong by using it. At some point I want to give Kaocha a go.

Test assertion library. I like testit and Juxt’s iota. They’re adequate, but I think there’s room to do better here.

Test data generation. I only just started using specmonstah for generating graphs of test data, but I’m excited. It’s so much nicer than writing the equivalent code by hand. There’s a bit of learning curve, though.

ClojureScript frontend

Build tool. Figwheel works very well and its getting better all the time. I’d either use it with Leiningen or directly with clj.

Front-end framework. re-frame is the way to go. Check out re-frame-10x for debugging.

Translations. Tempura works for me. I use a small Clojure tool for extracting the translatable strings into a PO file for editing with Poedit. The tool is proprietary right now but I hope to open source it.

General tools

clojure.spec helpers. Expound makes the spec error messages human-readable and Orchestra instruments the function return values.

Data manipulation utilities. I use the combination of Potpuri, xforms, and Specter. Potpuri is an old-fashioned “missing parts of clojure.core” library and xforms is the same for transducers. Specter is the closest thing to lenses for Clojure. It’s powerful but takes some time to learn. I recommend trying it out for some simple tasks – soon you’ll see opportunities for it everywhere.

What about …?

I haven’t included any SQL libraries, HTTP clients or servers, or async libraries, because I don’t have a clear recommendation for any of these (important!) categories.


Comments or questions? Send me an e-mail.