Stimulus.js
A minimal JavaScript framework for adding small, targeted behaviors to server-rendered HTML
Stimulus is a lightweight JavaScript framework that attaches reusable 'controllers' to existing server-rendered HTML using data attributes, designed to add small amounts of interactivity without taking ownership of the DOM.
Definition
Stimulus is a lightweight JavaScript framework that attaches reusable 'controllers' to existing server-rendered HTML using data attributes, designed to add small amounts of interactivity without taking ownership of the DOM.
Overview
Stimulus takes a deliberately modest view of what JavaScript on the web should do. Where frameworks like React or Vue treat JavaScript as the source of truth that generates the DOM, Stimulus assumes the HTML already exists — rendered by the server — and JavaScript's job is only to enhance it: toggling a class, submitting a form automatically, showing and hiding an element, or debouncing an input. This makes it a natural companion to Turbo as part of the Hotwire stack, since Turbo handles page-level navigation and updates while Stimulus handles the small interactive behaviors within a page. A Stimulus application is organized around controllers, small JavaScript classes that connect to DOM elements via `data-controller` attributes in the HTML. Within a controller, `data-target` attributes reference specific child elements the controller needs to read or manipulate, and `data-action` attributes wire up DOM events (clicks, input changes, form submissions) to controller methods, all declared directly in HTML rather than through imperative event-listener setup code. Controllers also support typed values and CSS classes passed in through data attributes, letting server-rendered templates configure controller behavior without any client-side data-fetching. Because Stimulus never generates HTML itself, it has no virtual DOM, no templating language, and no component tree to reconcile — it simply observes the DOM for elements matching its data attributes and connects or disconnects controllers as those elements appear or disappear, including elements swapped in by Turbo. This makes it lightweight (a few kilobytes) and easy to introduce incrementally into an existing server-rendered application, one controller at a time, without restructuring how pages are built. It's most associated with Ruby on Rails, where it ships as part of the default Hotwire stack, but like Turbo it is backend-agnostic and works with any server that renders HTML.
Key Features
- Controllers attach behavior to existing HTML via data-controller attributes
- Declarative event wiring through data-action attributes instead of manual listeners
- data-target attributes reference specific elements a controller manipulates
- Typed values and CSS classes configured directly through HTML data attributes
- No virtual DOM or templating — enhances server-rendered markup rather than generating it
- Automatically connects/disconnects controllers as elements are added or removed, including via Turbo
- Minimal footprint, well suited to progressive enhancement of existing pages
- Ships as the default JavaScript layer in Rails' Hotwire stack
Use Cases
Alternatives
History
Stimulus is described by its authors as "a modest JavaScript framework for the HTML you already have." It was created by Basecamp (37signals) and released as version 1.0 on January 30, 2018. Rather than taking over rendering like a single-page-app framework, Stimulus augments server-rendered HTML with small amounts of behavior through three simple concepts — controllers, actions, and targets — connected via data attributes in the markup. It was built because the team felt mainstream frameworks didn't fit their HTML-first way of building software, where JavaScript assists the page rather than owning it. Authored in TypeScript, Stimulus became a cornerstone of the Hotwire stack alongside Turbo.
Sources
- Stimulus — official handbook (origin) · as of 2026-07-17
- Stimulus on GitHub — hotwired/stimulus · as of 2026-07-17