Skip to main content
The 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.
Let your agent build it. The Ollie Shop skill ships with projects created by npx create-ollie-shop and knows the message types and when surfacing one beats failing silently.
Prompt
Don’t have the skill yet? Install it.

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: a ServerError (the object useCheckoutAction gives onError). 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 (error outranks warning, then info, then success).
  • 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) or clearAll(), or the template’s own rendering removes them.

Example

The example below shows two different messages, a success and an error To achieve the result in the example above:

Examples per action

addMessage(input)

removeMessage(messageId)

clearAll()