Sonner
Opinionated toast notification component for React applications.
3. Used by agents' projects
Dependency in 584 public GitHub projects set up for AI coding agents that we scanned (9.3%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error
What Sonner does
Sonner is built around its defaults: it calls itself "opinionated", a builder picked it because it looks good and stacks sensibly with no configuration, and Supabase's design system turns that styling off with <code>unstyled: true</code> to apply its own.
Sonner popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How Sonner is used
- Sonner is a dependency in 584 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (12.0% of the 4,867 JavaScript/TypeScript ones), #4 of 230 in ui components and icons.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 2,401; those are left out of every share on this page.
- The most used alternative in our scan is React Hot Toast (76 projects).
- Projects that use it most often also use Lucide React (96.4%), clsx (95.7%), Tailwind Merge (95.4%).
- It is more common in projects set up for Kiro (13.6%) than for Gemini CLI (7.2%).
By coding agent
Often used with
Sonner in practice
Strengths
peal.dev describes setup as two lines: add the Toaster once, then call <code>toast()</code> anywhere. They point out there are no context providers and nothing to wrap around the app.
The getting-started docs say the Toaster can be placed anywhere. That includes a Next.js <code>layout.tsx</code> that is a server component.
peal.dev says <code>toast.promise()</code> is the variant they use most. It handles the loading, success and error states and updates the same toast instead of showing three separate ones.
The <code>position</code> prop takes six values, from <code>top-left</code> to <code>bottom-right</code>. The site notes that the swipe direction changes with the position you choose.
Watch out for
In the Next.js App Router, Server Actions run on the server and cannot call <code>toast()</code>. peal.dev returns a result from the action and fires the toast in a client component.
peal.dev writes that toasts needing heavy styling outside Sonner's design system, or fully custom JSX in each toast, get more room in React Hot Toast.
peal.dev says Sonner "handles this somewhat" when someone clicks submit several times. In their view, you still need to debounce the action itself.
Mount the Toaster and fire a toast
import { Toaster, toast } from 'sonner';
// ...
function App() {
return (
<div>
<Toaster />
<button onClick={() => toast('My first toast')}>Give me a toast</button>
</div>
);
}More about Sonner
Funding
- GitHub Sponsors: https://github.com/emilkowalski
- 4 GitHub sponsors
Agent Skills for it
- : Skills for Designers and Engineers.
Head to head
- Sonner vs React Hot Toast used together in 27 projects
Packages around it
- lucide-react: Icon set
- clsx: Conditional class names
- tailwind-merge: Tailwind class merging
- class-variance-authority: Variant class names
- @radix-ui: Headless UI primitives
- next-themes: Theme switching
More in UI components and icons
Alternatives
Sonner This page
Lightweight, customizable toast notification component library for React.
Get started
Install it.
npm install sonnerRules for your agent
## Sonner
- Install with `npm install sonner`. The getting-started docs show `pnpm i sonner`.
- Add `<Toaster />` to the app. The site says to render it in the root of your app. In Next.js it can go in `layout.tsx`, even when that file is a server component.
- Import `toast` from `'sonner'` and call `toast()` where the event happens. Do not add a context provider; peal.dev notes none is needed.
- Pass options as an object in the second argument to `toast()`. Use `toast.success`, `toast.error`, `toast.warning` and `toast.promise` for typed toasts.
- Do not call `toast()` inside a Server Action. Return a result from the action and fire the toast from a client component.
- Configure the toaster with props on `<Toaster />`: `position` for placement, `visibleToasts` for how many toasts show, `expand` and `richColors`.
- Do not use a toast as the only feedback for field validation. Supabase's docs say to use FormMessage or FieldError beside the field.