Sonner

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

Library
npm
v2.0.8
12,867stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
67/100Good
Development Activity56
Maintenance56
Community64
Maturity52
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture78
Code Quality60
Innovation85
Learning Curve45

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 109 apps in this directory

TypeScript
99%
Other

Activepieces

Automation · AI Assistants

23,887

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
65
Dependency
Built with
TypeScript99%
Updated today
TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

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
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
86%
MIT

Agents Observe

Developer Tools

652

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
71
Repo Health
67
Technical
77
Dependency
Built with
TypeScript86%
JavaScript11%
Updated 4 weeks ago
TypeScript
84%
MIT

Amical

Note Taking · AI Assistants

1,495

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

View details
79
Repo Health
82
Technical
67
Dependency
Built with
TypeScript84%
Updated 3 weeks ago
TypeScript
51%
MIT

Anarlog

Note Taking · AI Assistants · Productivity

9,087

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
69
Dependency
Built with
TypeScript51%
Rust38%
Updated today
Python
68%
Other

AutoGPT

Automation · Productivity · AI Assistants

186,687

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
67
Dependency
Built with
Python68%
TypeScript31%
Updated today
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
46
Repo Health
64
Technical
76
Dependency
Built with
TypeScript100%
Updated 1 weeks ago
TypeScript
49%
AGPL 3.0

BrowserOS

Browser · AI Assistants

13,248

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
69
Dependency
Built with
TypeScript49%
Rust22%
Python16%
Updated today
Java
73%
Other

ByteChef

Automation · AI Agents

990

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

View details
81
Repo Health
82
Technical
73
Dependency
Built with
Java73%
TypeScript26%
Updated 2 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

Search