Skip to content

useConfirm

useConfirm(): ConfirmFn

Defined in: packages/ui/src/hooks/use-confirm.ts:47

Returns an imperative ConfirmFn that opens a confirmation dialog and resolves to true (confirmed) or false (cancelled/dismissed).

Must be used within a ConfirmProvider — typically supplied by the Joy UI plugin or a custom UI plugin implementation.

ConfirmFn

A ConfirmFn that accepts ConfirmOptions and returns a Promise<boolean>.

If called outside of a ConfirmProvider.

function DangerZone() {
const confirm = useConfirm();
async function handleDelete() {
const ok = await confirm({
title: "Delete account",
description: "This action cannot be undone.",
confirmLabel: "Delete",
variant: "danger",
});
if (ok) { /* proceed */ }
}
return <button onClick={handleDelete}>Delete</button>;
}