Open-source project
reagent-project/reagent avatar
reagent-project/reagent

Reagent turns React components into Clojure functions

A minimalistic ClojureScript interface to React.js

4,898 stars412 forksClojureMIT

At a glance

What is it?
Reagent is a ClojureScript interface to React where a component is a plain function returning a Hiccup style vector, and state is a Reagent atom whose deref triggers the re-render. The trade is that React itself comes from npm, and this repository carries two build paths and two React version lines.
Who is it for?
Reagent fits a team that already writes ClojureScript and wants React's renderer without JSX or a component class per screen. It does not fit a team that wants one dependency: React has to come from npm, React 18 lives behind a separate cljsjs path and a second package manifest, and there are no GitHub releases, so versions are pinned through Clojars and the cljdoc CURRENT page.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly Clojure, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • reagent-project/reagent4,898 ★ · +10
Star history
Repository2026-09-232026-11-15
reagent-project/reagent4.9k4.9k

10 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

A component is a function that returns a keyword vector

There is no JSX and no component class in the normal path. A component is a `defn` that returns a vector of keywords, with class names written as `:p.someclass` and attributes as a map:

clj
(defn some-component []
  [:div
   [:h3 "I am a component!"]
   [:p.someclass
    "I have " [:strong "bold"]
    [:span {:style {:color "red"}} " and red"]
    " text."]])

Nesting is literal nesting, because a child component is just called inside the parent's vector:

clj
(defn calling-component []
  [:div "Parent component"
   [some-component]])

Properties are ordinary function arguments, so a child is a function of its parameters and nothing else:

clj
(defn child [name]
  [:p "Hi, I am " name])

(defn parent []
  [child "Foo Bar"])

One convenience arrived in version 0.8: the `:class` attribute accepts a collection and drops nil values, so a conditional class no longer needs string surgery.

clj
[:div {:class ["a-class" (when active? "active") "b-class"]}]

Deref on a reagent.core atom is what schedules the re-render

State is an atom from `reagent.core`, and any component that dereferences it is re-rendered when it changes:

clj
(defonce click-count (r/atom 0))

(defn state-ful-with-atom []
  [:div {:on-click #(swap! click-count inc)}
   "I have been clicked " @click-count " times."])

There is no subscribe call and no explicit setState. That is also why holding state outside the tree is easy to do wrong: a deref inside a component that renders on a timer pulls that component on every tick.

Setup work on first render has its own convention. Instead of a lifecycle callback, the component function returns another function, and that inner function does the drawing:

clj
(defn timer-component []
  (let [seconds-elapsed (r/atom 0)]
    (fn []
      (js/setTimeout #(swap! seconds-elapsed inc) 1000)
      [:div
       "Seconds Elapsed: " @seconds-elapsed])))

React's own callbacks such as `getInitialState` and `componentWillMount` are then avoidable most of the time. They remain reachable through `reagent.core/create-class` or through metadata attached to a component function, which is how the mount callback below reads the DOM node:

clj
(defonce my-html (r/atom ""))

(defn plain-component []
  [:p "My html is " @my-html])

(def component-with-callback
  (with-meta plain-component
    {:component-did-mount
     (fn [this]
       (reset! my-html (.-innerHTML (rd/dom-node this))))}))

Mounting means naming a DOM node and requiring two namespaces

A tree only reaches the page when something renders it into a node, and the namespace block is the whole setup surface most applications write:

clj
(ns example
  (:require [reagent.core :as r]
            [reagent.dom :as rd]))

`reagent.core` gives you `atom` and `create-class`; `reagent.dom` gives you the render call and the node lookup used by the metadata callback above. The render itself takes a component and a DOM node:

clj
(defn mount-it []
  (rd/render [parent] (.-body js/document)))

Note what is missing from that call. There is no wrapper component, no provider, no hydration step, and no key management shown, because those are React's own concerns rather than Reagent's. That also means the escape hatch is always the React API underneath: whenever the vector form stops being convenient, the code goes back to `create-class` or to raw interop.

React comes from npm, and the dependency line lives in project.clj

Adding Reagent to an existing project means editing `project.clj` with the dependency published on Clojars. React itself is a separate job, and the version named here is exact:

The project states that a more recent minor or patch version of React is safe to use in your application, so the pinned pair above is a floor rather than a lock. React 18 or older is a different path entirely: the doc directory carries `reagent1.md`, which routes React 18 and earlier through cljsjs packages instead of npm.

The same split runs through the renderer. Reagent is not tied to react-dom alone, and `doc/ReactRenderers.md` covers the other renderers it can drive. For a team picking a library this matters more than the syntax: the version of React you get, and which renderer consumes it, are decisions you make in package.json, while the component code you write stays the same.

Documentation is split the same way. The released API docs are on cljdoc under reagent/reagent/CURRENT, the docs built from the `master` branch sit at reagent-project.github.io/docs/master/, and the tutorials and FAQ live in the `doc/` directory of the repository. A project on an older release is reading a different API reference than a project tracking master.

Two build paths sit in one repository, and they pin different Node versions

The npm manifest is private, starts a Leiningen driven figwheel client, and pins the toolchain rather than the library:

json
{
  "name": "@reagent-project/reagent",
  "private": true,
  "scripts": {
    "start": "lein figwheel client-npm"
  },
  "packageManager": "npm@^11",
  "engines": {
    "node": "24",
    "npm": "11"
  },
  "devDependencies": {
    "@cljs-oss/module-deps": "1.1.1",
    "karma": "6.4.4",
    "karma-chrome-launcher": "3.2.0",
    "karma-cli": "2.0.0",
    "karma-cljs-test": "0.1.0",
    "karma-coverage": "2.2.1",
    "karma-junit-reporter": "2.0.1",
    "karma-sourcemap-loader": "0.4.0",
    "karma-webpack": "5.0.1",
    "md5-file": "5.0.0",
    "prop-types": "15.8.1",
    "react": "19.2.3",
    "react-dom": "19.2.3",
    "shadow-cljs": "3.2.1",
    "webpack": "5.102.0",
    "webpack-cli": "6.0.1"
  },
  "optionalDependencies": {
    "fsevents": "^2.3.3"
  }
}

So the repository supports figwheel through Leiningen and shadow-cljs at the same time, and the build config files match that: `project.clj`, `shadow-cljs.edn`, `deps.edn`, and `bb.edn` all sit at the root. Tests run on Karma with a Chrome launcher and cljs test bindings, driven by `run-tests.sh` and `prepare-tests.sh`, and `react-18-package.json` with its lock file exist to keep the older React line buildable. Two manifests for two React lines is the clearest signal that the version question is real work, not a footnote.

The rest of the root is tooling and content: `build-docs.sh`, `build-docs-index.sh`, and `build-example-site.sh` generate the published site, `.nvmrc` pins the Node version for contributors, and `demo/` and `examples/` hold the sample applications, alongside `prerender/` and `outsite/`.

The speed claim rests on shouldComponentUpdate and one 79K example

The performance section is short and hedged in the project's own words: React is fast, Reagent should even be faster than plain JavaScript React a lot of the time, and the stated reason is that ClojureScript lets the library skip unnecessary rendering through judicious use of React's `shouldComponentUpdate`. The claim that ClojureScript overhead is kept down rests on caching.

The only number given is a bundle size: the todomvc example comes in at roughly 79K gzipped with advanced compilation, and the code size is described as a little bigger than React.js but still quite small. No benchmark table, no component counts, and no hardware are published, so the figure you can verify is the bundle size and nothing else.

The design has two documented sources. The idea and some of the code for atom like components come from pump, and the reactive atom idea plus more code comes from reflex. That lineage explains the shape of the API: the re-render trigger is a deref, not a subscription, and everything else is a Clojure function around it.

What Reagent leaves to you

Four gaps decide whether it fits. First, versions. The repository has no GitHub releases, so a dependency line has to be pinned to a Clojars version and read against the cljdoc CURRENT page; `CHANGELOG.md` and `ROADMAP.md` are the only in repository history, and neither appears in the README.

Second, React itself. Reagent does not vendor React, and staying on React 18 means following `doc/reagent1.md` instead of the npm command above.

Third, lifecycle and rendering edge cases stay with you. `create-class` and attached metadata are documented as available, which is also an admission that the plain function form does not cover every case, and non react-dom renderers are documented in a separate file rather than in the main flow.

Fourth, the surrounding links are uneven. The README links paid video courses, including courses on re-frame, with a $30 affiliate discount attached to the links. The license is MIT, the default branch is `master`, and the last push to the repository is dated 22 October 2026, so nothing here suggests an abandoned project, but a plan that depends on upgrade notes has to read CHANGELOG.md directly.

Editorial conclusion

Reagent fits a team that already writes ClojureScript and wants React's renderer without JSX or a component class per screen. It does not fit a team that wants one dependency: React has to come from npm, React 18 lives behind a separate cljsjs path and a second package manifest, and there are no GitHub releases, so versions are pinned through Clojars and the cljdoc CURRENT page. Before adopting it, read doc/ for the tutorials and FAQ, check which React line your renderer needs, and measure your own bundle rather than trusting the speed claims.

Frequently asked questions

What is the reagent?

reagent-project/reagent is a minimalistic ClojureScript interface to React where components are plain ClojureScript functions, state lives in a reagent.core atom, and markup is Hiccup like vectors instead of JSX.

How do I install Reagent in an existing ClojureScript project?

Add the dependency from Clojars to `project.clj`, then install React from npm with `npm i [email protected] [email protected]`. A newer minor or patch version of React is considered safe; React 18 and older go through cljsjs packages instead, as described in `doc/reagent1.md`.

Do I need JSX or a React component class to write a Reagent component?

No. A component is a `defn` returning a vector such as `[:div [:h3 "I am a component!"]]`, children are called inside that vector, and properties are plain function arguments. React lifecycle callbacks remain available through `reagent.core/create-class` or metadata attached to a component function.

How does Reagent know when to re-render a component?

Any component that dereferences a `reagent.core` atom is re-rendered automatically when that atom changes, which is why the click counter example only needs `(defonce click-count (r/atom 0))` and a `swap!` inside `:on-click`. Work needed at first render is done by having the component function return another function that does the rendering.

Is Reagent still packaged for React 18 and other renderers?

Yes, through separate paths. React 18 and older versions come from cljsjs packages with the details in `doc/reagent1.md`, and the project is not tied to react-dom alone, with other renderers covered in `doc/ReactRenderers.md`. The repository also carries `react-18-package.json` next to the main npm manifest.

Official sources

  1. Issues
  2. License: MIT
  3. Project website
  4. README
  5. reagent-project/reagent on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/reagent-project-reagent.svg)](https://hysenlabs.com/projects/reagent-project-reagent)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/reagent-project-reagent.svg)](https://hysenlabs.com/projects/reagent-project-reagent)

Was this useful?