Gathering detailed insights and metrics for react-sweetalert2
Gathering detailed insights and metrics for react-sweetalert2
Gathering detailed insights and metrics for react-sweetalert2
Gathering detailed insights and metrics for react-sweetalert2
sweetalert2-react-content
Official sweetalert2 enhancer adding support for React elements as content.
sweetalert2-react
Declarative SweetAlert 2 in React
omerman-sweetalert2-react-content
Official sweetalert2 enhancer adding support for React elements as content.
react-sweetalert2-redux
This is an implementation of react-sweetalert2 with redux and redux-thunk
npm install react-sweetalert2
Typescript
Module System
Node Version
NPM Version
TypeScript (93.76%)
JavaScript (6.24%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
Apache-2.0 License
14 Stars
55 Commits
2 Forks
2 Watchers
10 Branches
2 Contributors
Updated on Apr 17, 2025
Latest Version
0.6.0
Package Id
react-sweetalert2@0.6.0
Unpacked Size
29.75 kB
Size
8.08 kB
File Count
12
NPM Version
9.5.1
Node Version
18.16.1
Published on
Jul 14, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
$ npm i react-sweetalert2
or
$ yarn add react-sweetalert2
1 2import React, { useState } from 'react'; 3import SweetAlert2 from 'react-sweetalert2'; 4 5export default function App(){ 6 const [swalProps, setSwalProps] = useState({}); 7 return ( 8 <div> 9 <button onClick={() => { 10 setSwalProps({ 11 show: true, 12 title: 'Basic Usage', 13 text: 'Hello World', 14 }); 15 }}> 16 Open 17 </button> 18 19 <SweetAlert2 {...swalProps} /> 20 </div> 21 ); 22} 23
1import React, { Component } from 'react'; 2import SweetAlert2 from 'react-sweetalert2'; 3 4export default class App extends Component{ 5 constructor(){ 6 super(); 7 8 this.state = { 9 swal: {} 10 } 11 } 12 13 render() { 14 return ( 15 <div> 16 <button onClick={() => { 17 this.setState({ 18 swal: { 19 show: true, 20 title: 'Basic Usage', 21 text: 'Hello World' 22 } 23 }); 24 }}>Alert</button> 25 <SweetAlert2 {...this.state.swal} /> 26 </div> 27 ); 28 } 29} 30 31 32
withSwal
functionswal
props into Functional Component1import React from 'react'; 2import { withSwal } from 'react-sweetalert2'; 3 4export default withSwal((props, ref) => { 5 const { swal, ...rest } = props; 6 7 function handleClick(){ 8 swal.fire({ 9 title: 'Example', 10 text: 'Swal injected', 11 icon: 'success', 12 }); 13 } 14 15 return ( 16 <button onClick={handleClick}> 17 Open 18 </button> 19 ); 20}); 21
swal
props into Class Component1import React from 'react'; 2import { withSwal } from 'react-sweetalert2'; 3 4class ExampleComponent extends Component { 5 6 function handleClick(){ 7 this.swal.fire({ 8 title: 'Example', 9 text: 'Swal injected', 10 icon: 'success', 11 }); 12 } 13 14 render(){ 15 return ( 16 <button onClick={this.handleClick.bind(this)}> 17 Open 18 </button> 19 ); 20 } 21} 22 23export default withSwal(ExampleComponent); 24
SweetAlert2
component1import React, { useState } from 'react'; 2import SweetAlert2 from 'react-sweetalert2'; 3 4export default function App(){ 5 const [swalProps, setSwalProps] = useState({}); 6 7 function handleClick(){ 8 setSwalProps({ 9 show: true, 10 title: 'Example', 11 text: 'Hello World', 12 }); 13 } 14 15 return ( 16 <div> 17 <button onClick={handleClick}> 18 Alert 19 </button> 20 <SweetAlert2 {...swalProps} 21 didOpen={() => { 22 // run when swal is opened... 23 }} 24 didClose={() => { 25 // run when swal is closed... 26 }} 27 onConfirm={result => { 28 // run when clieked in confirm and promise is resolved... 29 }} 30 onError={error => { 31 // run when promise rejected... 32 }} 33 onResolve={result => { 34 // run when promise is resolved... 35 }} 36 /> 37 </div> 38 ); 39}
swal
prop injected1import React from 'react'; 2import { withSwal } from 'react-sweetalert2'; 3 4export default withSwal(({ swal }, ref) => ( 5 <button onClick={e => { 6 swal.fire({ 7 title: 'Example', 8 text: 'Hello World', 9 didOpen: () => { 10 // run when swal is opened... 11 }, 12 didClose: () => { 13 // run when swal is closed... 14 } 15 }).then(result => { 16 // when confirmed and promise resolved... 17 }).catch(error => { 18 // when promise rejected... 19 }); 20 }}> 21 Show Alert 22 </button> 23)); 24
1import React, { useState } from 'react'; 2import SweetAlert2 from 'react-sweetalert2'; 3 4export default function App(){ 5 const [swalProps, setSwalProps] = useState({}); 6 7 function handleClick(){ 8 setSwalProps({ 9 show: true, 10 title: 'Example' 11 }); 12 } 13 14 return ( 15 <div> 16 <button onClick={handleClick}> 17 Alert 18 </button> 19 <SweetAlert2 {...swalProps}> 20 <h1> 21 Hello World! 22 </h1> 23 </SweetAlert2> 24 </div> 25 ); 26} 27
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
7 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5
Reason
6 existing vulnerabilities detected
Details
Reason
Found 0/26 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More