Description #
Alpine.js is a minimal JavaScript framework that uses a declarative syntax embedded directly in HTML to create interactive UIs. Its DSL (domain-specific language) allows developers to write reactive behavior inline using x-
attributes.
History #
Alpine.js was created by Caleb Porzio in 2020 as a lightweight alternative to heavy frameworks like Vue or React. It was designed to bring reactivity and interactivity to HTML without leaving the markup or writing JavaScript files.
Hello World Code #
<div x-data="{ message: 'Hello, World!' }">
<h1 x-text="message"></h1>
</div>
How to Run #
Option 1: Online
Try it in your browser: https://alpinejs.dev/playground
Option 2: Local
Include Alpine via CDN in any HTML file:
<script src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
Then add:
<div x-data="{ message: 'Hello, World!' }">
<h1 x-text="message"></h1>
</div>
Key Concepts #
- Uses
x-data
,x-text
,x-show
, etc. directly in HTML - Declarative, minimal syntax
- Inspired by Vue.js reactivity model
- Lightweight (~10kB gzipped)
- No build tools or bundling required
- Ideal for small interactivity needs
- Works well with server-rendered HTML
- Supports transitions, loops, and events
- Great for HTMX, Laravel, and static sites
- Open-source and well-documented
Try It Online #
https://alpinejs.dev/playground
Fun Facts #
- Often called the “Tailwind of JavaScript frameworks” due to its minimalist, utility-first approach
- Popular with Laravel developers for building interactive components without a full SPA
- The entire Alpine.js site is built with Alpine itself
Resources #
Official site
Docs or tutorial
GitHub or interpreter
Community or learning resources