Liking cljdoc? Tell your friends :D


example workflow

A user-friendly way of configuring Clojure apps with environment variables.

Latest version

Clojars Project


  • An app should document the configuration it requires.
  • Useful, user-friendly feedback should be provided for missing configuration.
  • The app should only request the config it actually needs.
  • Configuration requirements should be composable.
  • Configuration should be describable with simple Clojure data.


Defining config

(require '[enviable.core :as e])

;; Let's start be defining a very simple config that tries to pull a value from an the environment variable MY_VAR
(def config (e/var "MY_VAR"))

;; When MY_VAR=foo is present in environment...
(e/read-env config) ;; => "foo"

;; When MY_VAR is not present in environment...
(e/read-env config) ;; => An error map explaining that MY_VAR is missing

;; You can verify if the return type is an error using the error? function i.e.
(e/error? (e/read-env config))

;; Just reading one environment variable is probably not going to be much use to you, so you can specify multiple at once!
;; E.g. 
(def config {:server {:host (e/var "HOST")
                      :port (e/var "PORT")}
             :db {:uri (e/var "DB_URI")}})
;; Given an environment with HOST=localhost PORT=1234 DB_URI=postgresql://localhost:5432/mydb
(e/read-env config) ;; => {:server {:host "localhost" 
                    ;;              :port "1234"} 
                    ;;     :db {:uri "postgresql://localhost:5432/mydb"}}

;; If any of the values are missing from the environment, then
(e/read-env config) ;; => returns some error data indicating which variables are missing and present


  • parse-with
  • default-to
  • is-optional
  • describe



  • int-var
  • double-var
  • bool-var

CLI Output


  • cli/read-env

Configuring Components


  • Configurable / configuration
  • configure-system



  • lein examples.basic
  • lein examples.component




Copyright © 2021 John Cowie

This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at

This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at

Can you improve this documentation? These fine people already did:
John Cowie & John
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close