Alpine.js: Installing Alpine

Installing Alpine can be as simple as including the script tag in your HTML page:

<script defer src="[email protected]/dist/cdn.min.js"></script>

Or, you can add it as a JavaScript module into your project:

npm install alpinejs

And you can initialize it with

import Alpine from 'alpinejs'
window.Alpine = Alpine

You can choose the way you prefer.

Adding the script tag is the simplest as you automatically have the Alpine object available in the global object, and already initialized (you don’t have to manually call Alpine.start())

Lessons in this unit:

0: Introduction
1: ▶︎ Installing Alpine
2: The basics of Alpine
3: Events
4: Defining data
5: Looping
6: Binding user input to variables
7: Watching variables change
8: Stores
Want to learn more? Check out our courses