
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
react-confirm
Advanced tools
Create confirmation dialogs as simple as window.confirm()
, but with full customization and Promise-based API.
🎯 Simple confirmation dialogs
const result = await confirm({ message: 'Delete this item?' });
if (result) {
// User confirmed
}
🎨 Fully customizable UI - No built-in styling. Use your own components, UI libraries, or design system.
⚡ Promise-based API - Works seamlessly with async/await, no complex state management needed.
🔄 React Context support - Access your app's context, themes, and providers from within dialogs.
📦 Lightweight - No dependencies, small bundle size.
npm install react-confirm
import React from 'react';
import { confirmable, createConfirmation, type ConfirmDialogProps } from 'react-confirm';
const MyDialog = ({ show, proceed, message }: ConfirmDialogProps<{ message: string }, boolean>) => (
<div className={`dialog-overlay ${show ? 'show' : 'hide'}`}>
<div className="dialog">
<p>{message}</p>
<button onClick={() => proceed(true)}>Yes</button>
<button onClick={() => proceed(false)}>No</button>
</div>
</div>
);
export const confirm = createConfirmation(confirmable(MyDialog));
import { confirm } from './confirm';
const handleDelete = async (): Promise<void> => {
// Fully type-safe: message is required, result is boolean
const result = await confirm({
message: 'Are you sure you want to delete this item?'
});
if (result) {
// User confirmed - proceed with deletion
deleteItem();
}
};
// In your component
<button onClick={handleDelete}>Delete Item</button>
If your dialog needs to access React Context (themes, authentication, etc.), use the context-aware approach:
Key differences from Quick Start:
// 1. Import ContextAwareConfirmation instead of createConfirmation
import { confirmable, ContextAwareConfirmation, type ConfirmDialogProps } from 'react-confirm';
// 2. Add ConfirmationRoot to your app
function App(): JSX.Element {
return (
<ThemeProvider>
<div>
<ContextAwareConfirmation.ConfirmationRoot />
<YourAppContent />
</div>
</ThemeProvider>
);
}
// 3. Your dialog can now use context
const ThemedDialog = ({ show, proceed, message }: ConfirmDialogProps<Props, boolean>) => {
const theme = useContext(ThemeContext); // ✅ Context works!
// ... rest of dialog implementation
};
// 4. Use ContextAwareConfirmation.createConfirmation
const confirm = ContextAwareConfirmation.createConfirmation(confirmable(ThemedDialog));
TypeScript automatically infers types from your dialog's Props definition, making the confirmation function fully type-safe.
// Option 1: Using React.FC with ConfirmDialogProps
const Confirmation1: React.FC<ConfirmDialogProps<Props, Response>> = (props) => (<Dialog />);
// Option 2: Using ConfirmDialog type
const Confirmation2: ConfirmDialog<Props, Response> = (props) => (<Dialog />);
react-confirm
version 0.2.x or 0.3.xreact-confirm
version 0.1.xFor additional reference examples, you can also check the react-confirm-sample repository, which contains archived historical examples and some alternative implementations. Check the examples above first for the latest patterns.
FAQs
Small library which makes your Dialog component callable
The npm package react-confirm receives a total of 20,849 weekly downloads. As such, react-confirm popularity was classified as popular.
We found that react-confirm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.