Sonner

An opinionated, animated toast notification component for React with a tiny imperative API.

Library
npm
v2.0.8
13,016 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
63 /100 Good
Development Activity 40
Maintenance 56
Community 64
Maturity 52
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
76 /100 Good
Architecture 78
Code Quality 60
Innovation 85
Learning Curve 45

Sonner is an opinionated toast component for React created by Emil Kowalski, the designer behind notification systems at Vercel and Linear. It ships a single <Toaster /> component and an imperative toast() function that can be called from anywhere in a React tree — no context provider or prop drilling required — to trigger stacked, animated, swipeable toast notifications.

Under the hood a lightweight pub-sub store decouples toast state from the render tree, and the library includes first-class support for promise-based toasts (loading to success/error), rich colors, custom themes, and Next.js App Router client components, while remaining dependency-free at runtime.

What You Get

  • A <Toaster /> component and imperative toast() API with success/error/info/warning/loading variants
  • Built-in promise handling that maps loading, success, and error states to toast content automatically
  • Swipeable, stackable toasts with configurable position, gap, duration, and expand-on-hover behavior
  • Light/dark/system theme support and a richColors mode for semantic color-coded toasts
  • Zero runtime dependencies and a single dependency-free CSS file shipped alongside the JS

Common Use Cases

  • Confirming form submissions or API mutations with success/error toasts
  • Showing progress for async operations via toast.promise() (e.g. file uploads, checkout flows)
  • Surfacing background job status (e.g. ‘Deploy started’ to ‘Deploy succeeded’) without blocking the UI
  • Replacing native browser alerts with a dismissible, accessible, theme-aware notification system

Under The Hood

Architecture Sonner is a single-package React component library centered on an observer/pub-sub pattern in src/state.ts (the Observer class) that decouples imperative toast() calls from the render tree — calling toast.success(…) publishes to a subscriber list that the mounted <Toaster /> (src/index.tsx) picks up via ToastState.subscribe inside a useEffect, batching updates with ReactDOM.flushSync and requestAnimationFrame to avoid render-thrash. The Toaster component tracks per-toast heights (HeightT[]) and an offset/gap layout system to stack toasts, groups toasts by position (top-right, bottom-center, etc.) into separate <ol> lists, and delegates each toast’s swipe/dismiss/hover/timer lifecycle to the inner Toast component, which manages its own mount/removal/animation state locally via refs and timers rather than through the global store.

Tech Stack Pure TypeScript/React library (peer deps react/react-dom ^18 || ^19) with zero runtime dependencies — styling is a single hand-authored CSS file (src/styles.css, ~17KB) shipped alongside the JS rather than CSS-in-JS. Built with bunchee (a bundler for library authors) producing dual ESM/CJS output with type declarations (dist/index.mjs, dist/index.js, dist/index.d.ts). The repo is a pnpm+Turborepo monorepo (pnpm-workspace.yaml, turbo.json) housing the library alongside a docs website package; testing uses Playwright for e2e browser tests rather than a unit-test runner.

Code Quality Test coverage is a single Playwright e2e spec (test/tests/basic.spec.ts, 340 lines) driving the built Toaster in a real browser (opening, dismissing, swiping toasts) — there are no unit tests for state.ts’s Observer class or types. Source is fully typed (types.ts defines roughly 200 lines of exported interfaces: ToastT, ToasterProps, ToastClassnames, etc.), naming is consistent and descriptive, and error handling in state.ts’s promise() method carefully branches on Response/Error/plain-value results, with a try/catch fallback for older Safari’s matchMedia API (addListener) in index.tsx. index.tsx is a large (889-line) single file mixing the Toast and Toaster components plus utility functions, which increases the surface a contributor needs to hold in their head.

API Design The public API is minimal and idiomatic — a single <Toaster /> mounted once plus an imperative toast() function (and toast.success/error/info/warning/loading/promise/custom/dismiss) callable from anywhere in the tree without hooks or context providers, which the README demonstrates in under 10 lines. Object.assign is used to attach the typed sub-methods onto the base toast function, preserving full TypeScript intellisense. The promise() API elegantly maps loading/success/error states to toast content, including HTTP Response detection. Minor DX friction: dedicated getting-started docs live outside the repo (hosted at sonner.emilkowal.ski), and the ‘use client’ directive at the top of index.tsx/assets.tsx signals Next.js App Router awareness without being called out in the README.

Used by 117 apps in this directory

TypeScript
100%
Other

Activepieces

AI Assistants · Automation · Mcp

24,756

Open-source AI automation platform that converts 280+ workflow integrations into MCP servers for LLMs, with no-code builders and TypeScript extensibility.

View details
92
Repo Health
85
Technical
64
Dependency
Built with
TypeScript 100%
Updated 4 days ago
TypeScript
82%
Other

AFFiNE

Collaboration · Note Taking · Productivity

73,040

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
67
Dependency
Built with
TypeScript 82%
Rust 11%
Updated 5 days ago
TypeScript
86%
MIT

Agents Observe

Developer Tools

684

A real-time, fully local observability dashboard for Claude Code and Codex agent sessions — filtering, search, session replay, and token/cost breakdowns via an auto-starting MCP server.

View details
66
Repo Health
67
Technical
77
Dependency
Built with
TypeScript 86%
JavaScript 10%
Updated 4 weeks ago
TypeScript
89%
MIT

Amical

AI Assistants · Note Taking · Voice AI

1,540

Local-first AI dictation that understands your active app — private, offline, and built for speed.

View details
82
Repo Health
82
Technical
68
Dependency
Built with
TypeScript 89%
Updated 1 weeks ago
TypeScript
54%
MIT

Anarlog

AI Assistants · Note Taking · Productivity

9,404

Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.

View details
86
Repo Health
77
Technical
68
Dependency
Built with
TypeScript 54%
Rust 34%
Updated 4 days ago
Python
66%
Other

AutoGPT

AI Assistants · Automation · Productivity

187,596

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
66
Dependency
Built with
Python 66%
TypeScript 33%
Updated 4 days ago
TypeScript
100%
AGPL 3.0

BaseBuddy

CMS

7

A self-hosted content editor for existing Postgres or Supabase schemas — maps the tables you already have into a WordPress-like TipTap editor instead of requiring you to reshape your database around a CMS.

View details
31
Repo Health
64
Technical
73
Dependency
Built with
TypeScript 100%
Updated 1 months ago
TypeScript
45%
AGPL 3.0

BrowserOS

AI Assistants · Browser

13,763

The open-source agentic Chromium browser with native AI agents, MCP server, and visual workflow automation — your data never leaves your machine.

View details
87
Repo Health
82
Technical
68
Dependency
Built with
TypeScript 45%
Rust 23%
Python 18%
Updated 4 days ago
Java
72%
Other

ByteChef

AI Agents · Automation

1,003

Unified open-source platform for AI agent orchestration and workflow automation with 180+ connectors, MCP support, and durable execution.

View details
85
Repo Health
82
Technical
67
Dependency
Built with
Java 72%
TypeScript 28%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers