How to install Alpine.js with Laravel

npm install alpinejs

resources/js/app.js

import Alpine from "alpinejs";

window.Alpine = Alpine;

Alpine.start();
php artisan make:component layout

resources/views/components/layout.blade.php

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Laravel</title>

    @vite(['resources/css/app.css', 'resources/js/app.js'])
</head>

<body>
{{ $slot }}
</body>

</html>
npm run build