Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Alewa's avatar
Level 2

Laravel RealRahid Sweet Alert Error

I am using realrashid sweetalert in my laravel 6 and i am having a swal is not defined error, any help?

0 likes
4 replies
Alewa's avatar
Level 2

I just watch bitfumes laravel 6 sweetalert video on YouTube and I followed his installation, which I just have to add @incluce(alert::sweetalert) in my blade file to make it work but I am getting swal is not defined, so I don't know which code you want me to post, because I did not touch any code.

tinkerbell's avatar

in your js/app.js put this after installing sweetalert2 through npm

window.Swal = require('sweetalert2');

And make sure to have this in layout/app.blade.php

<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.29.2/sweetalert2.all.js"></script>

then in blade test it

@if (session('message'))
        <script>
                Swal.fire({
                title: 'Error!',
                text: 'Do you want to continue',
                icon: 'error',
                confirmButtonText: 'okay'
                });
        </script> 
@endif
keizah7's avatar

Did you included app.js in layout/app.blade.php?

Please or to participate in this conversation.