Install and get first example SweetAlert


By NPM/Yarn

NPM combined with a tool like Browserify or Webpack is the recommended method of installing SweetAlert.


npm install sweetalert --save


Then, simply import it into your application:


import swal from 'sweetalert';



You can also find SweetAlert on unpkg and jsDelivr and use the global swal variable.


<script src=""></script>


Example: Show an alert Hello world


<!DOCTYPE html>



        <script src=""></script>

        <p>Example Hello world</p>


        <button onclick="run()">Run</button>



            function run() {

                swal("Hello world!");







Result :