reagent-project / reagent
A minimalistic ClojureScript interface to React.js
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing reagent-project/reagent in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler viewA simple ClojureScript interface to React. Reagent provides a way to write efficient React components using (almost) nothing but plain ClojureScript functions. • **Detailed intro with live examples** • **News** • **Documentation, latest release** • **Documentation, next release: API docs, Tutorials and FAQ** • **Community discussion and support channels** • **#reagent** channel in Clojure Slack • **Commercial video material** • Learn Reagent Free, Learn Reagent Pro (Affiliate link, $30 discount) • Learn Re-frame Free, Learn Re-frame Pro (Affiliate link, $30 discount) • purelyfunctional.tv • Lambda Island Videos Usage To use Reagent in an existing project you add this to your dependencies in : And provide React using npm (when using e.g. Shadow-cljs) If there is a more recent minor or patch version of React available, it should be safe to use it in your application. If you want to keep using React 18 or older versions, you can also use cljsjs packages to provide React. Reagent isn't tied to only React-dom but should work with other renderers also. Examples Reagent uses Hiccup-like markup instead of JSX. It looks like this: > **Since version 0.8:** The attribute also supports collections of classes, and nil values are removed: > > You can use one component inside another: And pass properties from one component to another: You mount the component into the DOM like this: assuming we have imported Reagent like this: State is handled using Reagent's version of , like this: Any component that dereferences a will be automatically re-rendered. If you want to do some setting up when the component is first created, the component function can return a new function that will be called to do the actual rendering: This way you can avoid using React's lifecycle callbacks like and most of the time. But you can still use them if you want to, either using or by attaching meta-data to a component function: See the examples directory for more examples. Performance React is pretty darn fast, and so is Reagent. It should even be faster than plain old javascript React a lot of the time, since ClojureScript allows us to skip a lot of unnecessary rendering (through judicious use of React's ). The ClojureScript overhead is kept down, thanks to lots of caching. Code size is a little bigger than React.js, but still quite small. The todomvc example clocks in at roughly 79K gzipped, using advanced compilation. About The idea and some of the code for making components atom-like comes from pump. The reactive-atom idea (and some code) comes from reflex. The license is MIT.