www/apps/ui/app/hooks/use-prompt/page.mdx
import { HookValues } from "@/components/HookValues" import { ComponentReference } from "@/components/ComponentReference" import { ComponentExample } from "@/components/ComponentExample"
export const metadata = {
title: usePrompt,
}
This hook returns a function that prompts the user to confirm an action.
In this guide, you'll learn how to use the usePrompt hook.
import { usePrompt } from "@medusajs/ui"
const dialog = usePrompt()
const actionFunction = async () => {
const confirmed = await dialog({
title: "Are you sure?",
description: "Please confirm this action",
})
}
The dialog function returned by usePrompt accepts an object having the following properties:
The dialog function returns a Promise that resolves to a boolean indicating whether the user confirmed the action.