# How to start with clj + shadow-cljs + rum

**URL:** https://clojureverse.org/t/how-to-start-with-clj-shadow-cljs-rum/7403
**Category:** Beginners
**Created:** [March 28, 2021, 7:10pm UTC](https://clojureverse.org/t/how-to-start-with-clj-shadow-cljs-rum/7403 "2021-03-28T19:10:22Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![stephen](https://clojureverse.org/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@stephen](https://clojureverse.org/u/stephen)
#### Post date: [March 28, 2021, 7:10pm UTC](https://clojureverse.org/t/how-to-start-with-clj-shadow-cljs-rum/7403/1 "2021-03-28T19:10:23Z")

</div>

I would like to get started experimenting with a fullstack clojure/clojureScript application.  
To learn to understand the basic structure I’d like to use the most basic tooling, no lein, no figwheel, no boot, no luminus. Only Clojure (+ring +reitit +rum) and ClojureScript (+rum +shadow-cljs)  
What I try to get going is the following:

- a Clojure Server that serves a serverside (pre-)rendered rum component that gets fully hydrated from cljs
- all of that with that “great dynamic clojurey workflow” (instant live reloading)
- a live clj REPL
- a live cljs REPL

Can someone please point me in the right directions?  
The most promising template I found was [GitHub - mdiin/happlate: A template for awesome web apps, based on Hoplon, Postgresql and RPC communication.](https://github.com/mdiin/happlate) but I always get errors…

I would be really happy if someone could help me get started

---

<div class="post-metadata">

### Author: ![Serioga](https://clojureverse.org/user_avatar/clojureverse.org/serioga/32/5290_2.png) [@Serioga](https://clojureverse.org/u/Serioga)
#### Post date: [March 28, 2021, 8:28pm UTC](https://clojureverse.org/t/how-to-start-with-clj-shadow-cljs-rum/7403/2 "2021-03-28T20:28:46Z")

</div>

You can look at my (opinionated) template [GitHub - serioga/webapp-clojure-2020: Multi-page web application prototype with Clojure(Script)](https://github.com/serioga/webapp-clojure-2020)

---

<div class="post-metadata">

### Author: ![stephen](https://clojureverse.org/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@stephen](https://clojureverse.org/u/stephen)
#### Post date: [March 29, 2021, 8:20pm UTC](https://clojureverse.org/t/how-to-start-with-clj-shadow-cljs-rum/7403/3 "2021-03-29T20:20:38Z")

</div>

It took me quite a while, but I have a good place to start now:

> **[Steffen / Fullstack Clojure with Rum Template](https://gitlab.com/StephenBDT/fullstack-clojure-with-rum-template)**
>
> GitLab.com

Please give some feedback

---

<div class="post-metadata">

### Author: ![stephen](https://clojureverse.org/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@stephen](https://clojureverse.org/u/stephen)
#### Post date: [March 30, 2021, 9:18pm UTC](https://clojureverse.org/t/how-to-start-with-clj-shadow-cljs-rum/7403/4 "2021-03-30T21:18:49Z")

</div>

It is still not working. The first render with Shadow-Cljs works but when the file gets saved, shadow-cljs reloads and reexecutes the file and then the result is:

```auto
  45 | (rum/defc item [data]
  46 | [:div.item
  47 | [:div.picture (picture "https://t1p.de/adga")]
  48 | [:div.title (:title data)]])
------------------------------^-------------------------------------------------
Use of undeclared Var projectname.core/data
--------------------------------------------------------------------------------

```

All I do, is the following in `src/cljs/projectname.cljs`:

```auto
(ns projectname.core
  (:require [rum.core :as rum]))

(def item_data
  {:title "testitem"
   :main-picture-url "https://t1p.de/adga"})

(rum/defc picture [url]
  [:img {:src url :loading "lazy" :alt "Productpicture"}])

(rum/defc item [data]
  [:div.item
   [:div.picture (picture "https://t1p.de/adga")] ;;(:main-picture-url data))]
   [:div.title (:title data)]])

(defonce item_comp (item item_data))

(rum/mount item_comp (js/document.getElementById "item-container"))

```

the `defonce` is already a desperate attempt to fix this… ☹

---

<div class="post-metadata">

### Author: ![stephen](https://clojureverse.org/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@stephen](https://clojureverse.org/u/stephen)
#### Post date: [March 31, 2021, 1:21pm UTC](https://clojureverse.org/t/how-to-start-with-clj-shadow-cljs-rum/7403/5 "2021-03-31T13:21:44Z")

</div>

Okay, this seems to be a bug with rum. A bugreport was filed:

> <https://github.com/tonsky/rum/issues/233>
>
> 5 | (rum/defc hello-world \[g\]
> 6 | \[:div
> 7 | \[:h2 g\]
> \---------------^----------------------------------------------------------------
> Use of undeclared Var shadow-rum.core/g
> This happens when shadow-cljs reloads my...

---

<div class="post-metadata">

### Author: ![thheller](https://clojureverse.org/user_avatar/clojureverse.org/thheller/32/534_2.png) [@thheller](https://clojureverse.org/u/thheller)
#### Post date: [March 31, 2021, 1:43pm UTC](https://clojureverse.org/t/how-to-start-with-clj-shadow-cljs-rum/7403/6 "2021-03-31T13:43:21Z")

</div>

FWIW I just tested this and it is working completely fine without any warnings?

```auto
(ns projectname.core
  (:require [rum.core :as rum]))

(defonce app-state (atom {:text "Hello world!"}))

(rum/defc hello-world [data]
  [:div
   [:h1 (:text @app-state)]
   [:h3 "Edit this and watch it change!" (:foo data)]])

(defn start []
  ;; start is called by init and after code reloading finishes
  ;; this is controlled by the :after-load in the config
  (rum/mount (hello-world {:foo "bar"})
             (. js/document (getElementById "app"))))

(defn ^:export init []
  ;; init is called ONCE when the page loads
  ;; this is called in the index.html and must be exported
  ;; so it is available even in :advanced release builds
  (start))

(defn stop []
  ;; stop is called before any code is reloaded
  ;; this is controlled by :before-load in the config
  (js/console.log "stop"))

```

with

```auto
 :dependencies [[binaryage/devtools "0.9.7"]
                [rum "0.12.4"]
                ;; fork to support react 16
                ;; [ua.modnakasta/rum "0.11.0-2"]
                [org.roman01la/citrus "3.0.0" :exclusions [rum]]
                ]

```

running `shadow-cljs watch app` and `http://localhost:8700/`.

Anything I’m missing?

---

<div class="post-metadata">

### Author: ![stephen](https://clojureverse.org/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@stephen](https://clojureverse.org/u/stephen)
#### Post date: [March 31, 2021, 6:49pm UTC](https://clojureverse.org/t/how-to-start-with-clj-shadow-cljs-rum/7403/7 "2021-03-31T18:49:03Z")

</div>

I am beginning to question my sanity xD.  
I copy pasted the code you just quoted here and it WORKED!  
I did copy it from the state where it didnt!!  
maybe I am just not seeing right, and there is an obvious typo somewhere, if that is the case, I feel really sorry 🙂  
 ![trouble-with-rum-and-shadow-cljs](https://clojureverse.org/uploads/default/original/2X/f/f6ca2f9309ae15511194f68dbc2fc8a0c7691264.gif)

---

<div class="post-metadata">

### Author: ![system](https://clojureverse.org/uploads/default/original/2X/5/51079bf9e4b7d9466242c06cf1e43b9f8bd6da14.png) [@system](https://clojureverse.org/u/system)
#### Post date: [September 30, 2021, 6:49am UTC](https://clojureverse.org/t/how-to-start-with-clj-shadow-cljs-rum/7403/8 "2021-09-30T06:49:41Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
