## Alpine.js 3.x, CSP-compatible client-side reactivity Alpine.js is a minimal alternative to Vue/React for sprinkles of interactivity. Use its dedicated [CSP build](https://alpinejs.dev/advanced/csp), which avoids the standard build's `Function`-style evaluation and works without `'unsafe-eval'`. Keep complex behavior in a same-origin external component file; simple property and method references remain in `x-*` attributes. ```html
Content here

``` ```javascript // public/js/alpine-components.js, loaded before the deferred CSP runtime document.addEventListener('alpine:init', () => { Alpine.data('togglePanel', () => ({ open: false, toggle() { this.open = !this.open; } })); Alpine.data('nameForm', () => ({ first: '', last: '', get fullName() { return `Hello, ${this.first} ${this.last}`; } })); Alpine.data('itemList', () => ({ items: [], async load() { const response = await fetch('/api/items'); if (!response.ok) throw new Error('Item request failed'); this.items = await response.json(); } })); }); ``` Alpine pairs naturally with htmx: htmx swaps a server-rendered fragment in, Alpine handles whatever client-side state that fragment needs (open/close, optimistic toggles, form validation).