Become a member
to unlock all features

Create egghead account to access 5000+ tutorials and resources from expert developers.

Create account

    Connect a Stimulus Controller to your html


    The first thing you need to do is add the data-controller attribute the to html that you want to connect to Stimulus.

    We added data-controller="example" so Stimulus expects an example_controller.js file to exist.

    In our ExampleController class, we are going to use the connect method to show that we've connected our controller to the dom.