Skip to content

Stimulus

A small JavaScript framework that adds behavior to HTML you already have.

Stars
13.1k
Forks
444
Licence
MIT
Language
TypeScript
Last update
8 days ago
Type
Library

What it is

Stimulus is a JavaScript framework that adds interactive behavior to existing HTML. You mark elements with data attributes such as controllers, targets, and actions, then write a small controller class that responds to them. It does not render HTML itself, and it works with or without a build step.

  • Add a button that updates text on a page using a controller and an action attribute
  • Show or hide page sections in response to user input
  • Respond to updates from Ajax requests or Turbo page changes, which the README says Stimulus handles automatically

Great for

  • Developers who already render HTML on the server and want light interactivity
  • Teams pairing a server-rendered app with Turbo, as the README recommends
  • Projects that want a small framework instead of a full front-end app framework

Not ideal for

  • Teams building a full single-page app with client-side rendering, since Stimulus is explicitly not concerned with rendering HTML
  • Beginners with no HTML or JavaScript basics, since the README assumes you already have both
Step-by-step guide: how to use StimulusInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js (for the Yarn-based development workflow in the README)

    Install dependencies for local development

    yarn install
  2. 2

    Run it

    • Read the Stimulus Handbook introduction at stimulus.hotwired.dev/handbook/introduction
    • Add a data-controller attribute to a div in your HTML
    • Write a controller that extends Controller and declares static targets
    • Add a data-action attribute to trigger a controller method
    • Run yarn start to view the local examples if you cloned the repository
  3. 3

    Get the most out of it

    • Pair Stimulus with Turbo for page navigation and partial updates, as the README recommends
    • Use the Stimulus Reference at stimulus.hotwired.dev/reference/controllers for full API details
    • Ask questions on the Hotwire Discourse community forum

Downloads

Strengths

  • Small scope: it augments HTML rather than replacing your front end
  • Works with any asset packaging system, or with a plain script tag and no build step
  • Watches the DOM and manages controller lifecycle as elements appear and disappear

Trade-offs

  • Not a rendering solution, so you need another way to produce HTML
  • The README is brief on advanced usage, so details live in the external Handbook and Reference

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.