Skip to content

useActionToast

useActionToast(descriptor, config): void

Defined in: packages/ui/src/hooks/use-action-toast.ts:42

Automatically shows toast notifications when @cfast/actions results arrive.

Watches all configured actions via their ClientDescriptor and triggers success or error toasts when their result data changes. Internally uses useToast and useActions from @cfast/actions/client.

Must be used within both a ToastProvider and an actions context (i.e., inside app.Provider).

ClientDescriptor

Client-side action descriptor from @cfast/actions, typically composed.client from a createActions() call.

ActionToastConfig

Map of action names to toast messages. Only actions listed here are watched; others are ignored.

void

void

// In a route component:
useActionToast(composed.client, {
deletePost: { success: "Post deleted", error: "Failed to delete" },
publishPost: { success: "Post published" },
});