Using Other ClojureScript REPLs

While these days most people are using figwheel and shadow-cljs, CIDER supports other ClojureScript REPLs as well. This section of the user manual is dedicated to them.

Node.js REPL

Make sure node.js is installed and that the node binary is on Emacs’s exec-path.

ClojureScript’s Node.js REPL is really simple to setup, as it doesn’t require you to fiddle with your project’s dependencies. All you need to do is:

  1. Open some file in your project.

  2. Type M-x cider-jack-in-cljs RET.

  3. Choose the node option when prompted about the ClojureScript REPL type you want to use.

Weasel

Using Weasel, you can have a browser-connected REPL.

  1. Add [weasel "0.7.1"] to your project’s :dependencies.

  2. Type M-x cider-jack-in-cljs RET and choose the Weasel option when prompted about the ClojureScript REPL type you want to use.

  3. Add this to your ClojureScript code:

    (ns my.cljs.core
      (:require [weasel.repl :as repl]))
    (repl/connect "ws://localhost:9001")
  4. Once connected you can start evaluating code in the REPL and you’ll see the results in your browser.

    cljs.user> (js/alert "Hello world!")

Provided that a Piggieback-enabled ClojureScript environment is active in your REPL session, code loading and evaluation will work seamlessly regardless of the presence of the cider-nrepl middleware. If the middleware is present then most other features of CIDER will also be enabled (including code completion, documentation lookup, the namespace browser, and macroexpansion).

For more information on Weasel you should consult its documentation.

Node-based ClojureScript runtimes

Some ClojureScript runtimes - such as nbb - run on Node and bring their own nREPL server, so they don’t go through Piggieback. They’re still reached through the ClojureScript commands: jack in with M-x cider-jack-in-cljs, or connect to an already-running server with M-x cider-connect-cljs.

These runtimes live in the Alternative Platforms section of this manual, since they’re full Clojure-like runtimes rather than just another ClojureScript REPL flavor.