# Sonner — card for AI agents

Opinionated toast notification component for React applications.

Category: UI components and icons · npm package `sonner` · latest version 2.0.8 (checked 2026-11-01)
Install: `npm install sonner`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## Sonner
- Install with `npm install sonner`. The getting-started docs show `pnpm i sonner`.
- Add `` 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 ``: `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.

## Agent Skills for it
- Official: emilkowalski/skills (20 skills): `npx skills add emilkowalski/skills`

## What it is
- Sonner calls itself "an opinionated toast component for React." The GitHub repository was created on 2023-02-23 and is MIT licensed.
- Setup has two parts. You add `<Toaster />` to your app, and the README says it "will be the place where all your toasts will be rendered." After that, you import `toast` from `sonner` and use `toast()` from anywhere in the app.
- The website demonstrates the built-in options. The toast types are default, description, success, info, warning, error, action, promise and custom. The site also shows six screen positions, an expand mode, rich colors, a close button and a headless mode. Options go in an object passed as the second argument to `toast()`.

## Caveats
- Server Actions cannot fire toasts: In the Next.js App Router, Server Actions run on the server and cannot call `toast()`. peal.dev returns a result from the action and fires the toast in a client component.
- Heavy custom designs fit less well: 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.
- Rapid clicks still need debouncing: peal.dev says Sonner "handles this somewhat" when someone clicks submit several times. In their view, you still need to debounce the action itself.
- Update-by-id is less explicit: peal.dev notes that Sonner supports updating a toast by id. They find React Hot Toast's API for this a bit more explicit.
- Action toasts need a longer duration: A toast with an Undo button can disappear before a keyboard user reaches it. peal.dev sets `duration` to 8000 on any toast that has an action button.

## Numbers (AgentGid data)
- Gid Score: 81.8 (#71 of all tools, 4 of 230 in its category)
- Used in 584 public projects set up for AI coding agents (9.3%)
- Downloads last week: 61,893,599 (as of 2026-11-24), +19.4% over 4 weeks
- GitHub stars: 13,262 (as of 2026-11-24)
- Last push: 2026-08-10

## Often used with
Lucide React 96.4%, clsx 95.7%, Tailwind Merge 95.4%, Class Variance Authority 94.2%, Radix UI 79.3%, React 99.8%

## Checked alternatives (same job)
- React Hot Toast: https://agentgid.com/tools/react-hot-toast/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/sonner/
- Homepage: https://sonner.emilkowal.ski/
- Repository: https://github.com/emilkowalski/sonner
- Source: https://github.com/emilkowalski/sonner#readme
- Source: https://github.com/emilkowalski/sonner
- Source: https://github.com/emilkowalski/sonner/releases
- Source: https://sonner.emilkowal.ski
- Source: https://sonner.emilkowal.ski/getting-started

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
