Socket
Socket
Sign inDemoInstall

@hotwired/stimulus

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hotwired/stimulus

A modest JavaScript framework for the HTML you already have.


Version published
Maintainers
1
Created

What is @hotwired/stimulus?

@hotwired/stimulus is a JavaScript framework that enhances the interactivity of web applications by providing a lightweight, unobtrusive way to add behavior to HTML elements. It follows the principles of the Stimulus framework, which emphasizes simplicity and convention over configuration.

What are @hotwired/stimulus's main functionalities?

Controller Definition

Defines a Stimulus controller that logs a message to the console when connected to the DOM.

```javascript
import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
  connect() {
    console.log("Hello, Stimulus!");
  }
}
```

Data Attributes

Uses data attributes to bind HTML elements to Stimulus controllers and actions.

```html
<div data-controller="example">
  <button data-action="click->example#sayHello">Click me</button>
</div>

<script>
  import { Application } from "@hotwired/stimulus";
  import ExampleController from "./example_controller";

  const application = Application.start();
  application.register("example", ExampleController);
</script>
```

Targets

Defines targets within a controller to easily reference and manipulate specific elements.

```html
<div data-controller="example">
  <input data-example-target="name" type="text">
  <button data-action="click->example#greet">Greet</button>
</div>

<script>
  import { Controller } from "@hotwired/stimulus";

  export default class extends Controller {
    static targets = [ "name" ];

    greet() {
      alert(`Hello, ${this.nameTarget.value}!`);
    }
  }
</script>
```

Other packages similar to @hotwired/stimulus

FAQs

Package last updated on 07 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc