binder.js is a JavaScript library to help you build custom web components to use in your server rendered templates!
Clicks: {this.data.clicks}
<click-counter> <p @render>Clicks: {this.data.clicks}</p> <button @click="this.count()">Click me!</button> </click-counter> <script type="module"> import { registerControllers, Controller } from '/static/js/binder/binder.js'; class ClickCounter extends Controller { init() { this.data.clicks = 0; } count() { this.data.clicks++; this.render(); } } registerControllers(ClickCounter); </script>
You can get started now by checking out the quick start instructions or learn more from our guide.