# Stimulus Integration
> **Preview ecosystem guide:** Asset Pipeline is not part of the Amber 2.0.0-beta.2
> core web-app release gate. Its package version, API, and platform support may
> change independently. Do not add a personal fork as a default dependency.
The Asset Pipeline provides first-class support for Stimulus, the modest JavaScript framework from Hotwire. It automatically detects controllers, handles imports, and registers them with the Stimulus application.
## Basic Setup
### Configure Stimulus
```crystal
front_loader = AssetPipeline::FrontLoader.new(
js_source_path: Path["src/javascript"],
js_output_path: Path["public/javascript"]
) do |import_maps|
import_map = AssetPipeline::ImportMap.new("application", Path["/javascript"])
# Add Stimulus framework
import_map.add_import(
"@hotwired/stimulus",
"https://cdn.jsdelivr.net/npm/@hotwired/stimulus@3.2.2/+esm",
preload: true
)
# Add controllers
import_map.add_import("HelloController", "hello_controller.js")
import_map.add_import("DropdownController", "dropdown_controller.js")
import_maps << import_map
end
```
### Render in Layout
```ecr
My App
<%= FRONT_LOADER.render_import_map_tag %>
<%= content %>
<%= FRONT_LOADER.render_stimulus_initialization_script %>
```
## Automatic Controller Detection
Controllers ending with "Controller" are automatically detected and registered:
```crystal
# These are detected as Stimulus controllers
import_map.add_import("HelloController", "hello_controller.js")
import_map.add_import("DropdownController", "dropdown_controller.js")
import_map.add_import("UserProfileController", "user_profile_controller.js")
# This is NOT detected (no "Controller" suffix)
import_map.add_import("utils", "utils.js")
```
### Name Conversion
PascalCase controller names are converted to kebab-case for registration:
| Import Name | Registered As | HTML Data Attribute |
|-------------|---------------|---------------------|
| `HelloController` | `hello` | `data-controller="hello"` |
| `DropdownController` | `dropdown` | `data-controller="dropdown"` |
| `UserProfileController` | `user-profile` | `data-controller="user-profile"` |
## Writing Controllers
### Basic Controller
```javascript
// src/javascript/hello_controller.js
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["name", "output"]
greet() {
const name = this.nameTarget.value || "World"
this.outputTarget.textContent = `Hello, ${name}!`
}
}
```
### Using in HTML
```html