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.

Was this example helpful?

Usage#

Code
import { usePrompt } from "@medusajs/ui"
Code
const dialog = usePrompt()
const actionFunction = async () => {
  const confirmed = await dialog({
    title: "Are you sure?",
    description: "Please confirm this action",
  })
}

API Reference#

usePrompt Return Value#

Was this guide helpful?

Returned Dialog Parameters#

The dialog function returned by usePrompt accepts an object having the following properties:

Dialog Return Value#

The dialog function returns a Promise that resolves to a boolean indicating whether the user confirmed the action.


Examples#

Prompt with Verification Text#

Was this guide helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵