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
1const dialog = usePrompt()2const actionFunction = async () => {3  const confirmed = await dialog({4    title: "Are you sure?",5    description: "Please confirm this action",6  })7}

API Reference#

usePrompt Return Value#

NameTypeDescription
dialog
function
Async function used to display a new confirmation dialog.
Was this guide helpful?

Returned Dialog Parameters#

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

PropTypeDefault
title
string
-
description
string
-
variant
"danger"
|"confirmation"
"danger"
verificationText
string
-
verificationInstruction
string
"Please type {val} to confirm:"
cancelText
string
"Cancel"
confirmText
string
"Confirm"
Was this helpful?

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 Anything
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