| description | Use when adding, debugging, or migrating notification toasts in a shadcn ui project, mounting the top-level `<Toaster />` in your app root, calling `toast()` / `toast.success` / `toast.error` / `toast.warning` / `toast.info` / `toast.loading` / `toast.promise`, configuring the Toaster's `position`, `duration`, `expand`, `richColors`, or `closeButton` props, dismissing a toast programmatically via `toast.dismiss(id)`, wrapping a fetch / mutation with `toast.promise` for the loading -> success / error state machine, or removing dead `useToast()` hook calls left over from a pre-2026 shadcn project. Prevents the canonical toast failures : trying to import `useToast` from `@/components/ui/use-toast` (the file no longer exists ; the hook + the Radix-based Toast component were REMOVED per the shadcn 2026 changelog), calling `toast()` before any `<Toaster />` is mounted (the call is silently dropped), mounting two `<Toaster />` instances and getting duplicated stacks, calling `toast()` from inside a React Server Component (Sonner is client-only), forgetting `"use client"` on the component that calls `toast()`, and using `toast.promise` with only two of the three required states (loading + success without error, or success without loading) so the toast hangs or never settles. Covers the shadcn `Toaster` wrapper verbatim from `apps/v4/ registry/new-york-v4/ui/sonner.tsx` (icons, theme integration via next-themes, the CSS-variable bridge to shadcn's `--popover` / `--border` / `--radius` tokens), the upstream `sonner` package API (`toast`, `toast.success`, `toast.error`, `toast.warning`, `toast.info`, `toast.loading`, `toast.promise`, `toast.dismiss`, `toast.custom`), the six `position` values (top-left, top-center, top-right, bottom-left, bottom-center, bottom-right ; default bottom-right), the `duration` prop (default 4000ms, `Infinity` for sticky), `expand` (default true), `richColors` (semantic per-type colors), `closeButton` (X affordance on hover), the one-toaster-per-app rule, and the migration table from `useToast()` -> `toast()`. Keywords: shadcn toast, sonner, Toaster, useToast removed, useToast deprecated, where is useToast, migrate from useToast, toast.success, toast.error, toast.warning, toast.info, toast.loading, toast.promise, toast.dismiss, toast.custom, richColors, closeButton, position prop, duration prop, expand prop, top-right toast, bottom-right toast, sticky toast, Infinity duration, sonner not working, toast not showing, toast silent, toast nothing happens, no toast appears, Toaster not mounted, two toasters, duplicate toasts, toast in server component, RSC toast, "use client" toast, how do I show a notification, how do I show an error message, how do I notify the user, snackbar shadcn, notification shadcn, alert popup shadcn, fetch with toast, toast around fetch, loading toast pattern, optimistic ui toast.
|