useToast
useToast():
ToastApi
Defined in: packages/ui/src/hooks/use-toast.ts:40
Returns an imperative ToastApi for showing toast notifications.
Provides convenience methods (success, error, info, warning) as well
as a generic show method that accepts full ToastOptions.
Must be used within a ToastProvider — typically supplied by the Joy UI
plugin (backed by Sonner) or a custom UI plugin implementation.
Returns
Section titled “Returns”A ToastApi object with methods for each notification type.
Throws
Section titled “Throws”If called outside of a ToastProvider.
Example
Section titled “Example”function PublishButton() { const toast = useToast();
async function handlePublish() { try { await publishPost(); toast.success("Post published"); } catch (err) { toast.error("Failed to publish post"); } }
return <button onClick={handlePublish}>Publish</button>;}