useMessages hook manages the checkout’s notification messages (alerts, confirmations, errors). It lets you add, remove, and clear messages from any custom component; the template renders them.
Import
Usage
Return Value
Message
AddMessageInput
type is required, title is optional, and exactly one of these two:
content: the text or node to show.error: aServerError(the objectuseCheckoutActiongivesonError). The hook resolves it to the store’s translated message by looking up, in order, the platform error code, the error code, the error group, and finally a generic “unknown error” text. That way the shopper sees the same wording the native components use.
How the stack behaves
- At most three messages are shown at a time. When a fourth arrives, the oldest message with the lowest priority is dropped (
erroroutrankswarning, theninfo, thensuccess). - A message with the same type and text as one already shown is ignored, so retrying an action does not pile up duplicates.
- Messages are not dismissed automatically. They stay until you call
removeMessage(id)orclearAll(), or the template’s own rendering removes them.
Example
The example below shows two different messages, asuccess and an error
To achieve the result in the example above:
Examples per action
addMessage(input)
removeMessage(messageId)
clearAll()
Related
- useCheckoutAction: the source of the
ServerErrorobjectsaddMessagecan resolve - useNavigation: pair a blocked step with a message explaining why

