Skip to content

Instantly share code, notes, and snippets.

@chr15m
Last active November 11, 2025 09:17
Show Gist options
  • Select an option

  • Save chr15m/204f645c56a22aa39f2cdaab6a80bd66 to your computer and use it in GitHub Desktop.

Select an option

Save chr15m/204f645c56a22aa39f2cdaab6a80bd66 to your computer and use it in GitHub Desktop.
Run Reagent via Scittle in Node and output the result.
const cljs =`
(ns updater
(:require
[reagent.core :as r]
[reagent.dom :as rdom]))
(def state (r/atom nil))
(defn app []
[:div "Hello world!"]
[:button {:on-click #(swap! state update :val inc)} "Counter: " (:val @state)])
(rdom/render [app] (.getElementById js/document "app"))
`
const fs = require("fs")
const hd = require("happy-dom")
globalThis.ReactDOM = require("react-dom")
globalThis.React = require("react")
const window = new hd.Window()
globalThis.document = window.document
globalThis.window = window
const appDiv = document.createElement("div")
appDiv.id = "app"
document.body.appendChild(appDiv)
eval.call(globalThis, (fs.readFileSync("node_modules/scittle/dist/scittle.js", "utf8")))
eval.call(globalThis, (fs.readFileSync("node_modules/scittle/dist/scittle.reagent.js", "utf8")))
scittle.core.eval_string(cljs)
document.querySelector("button").click();
setTimeout(() => {
console.log(document.body.toString());
}, 0);
// $ node node-scittle-reagent.js
// <body><div id="app"><button>Counter: 1</button></div></body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment