Skip to content
Agents tracked: 440 Downloads (7d): 202M down 19.5% GitHub stars: 10.4M Releases (7d): 607 Agent status: 1 with issuesSince last limit reset: Claude 28d · Codex 0d Updated Oct 21, 2026

Sonner Examples You Can Edit and Run

5 small Sonner examples written by AgentGid from the official docs, one feature each. Every one runs in your browser: change the code and see the result at once, or describe a change and let AI rewrite it. The screenshots are taken from the same code by our server, which also checks that each example starts without errors.

Sonner: usage and stats 576 AI-built projects use it

Try them all in one place

import { useEffect, useState } from "react";
import { Toaster, toast } from "sonner";

const S = {
  page: { minHeight: "100vh", display: "flex", alignItems: "center", justifyContent: "center", background: "#111", fontFamily: "system-ui, sans-serif" },
  card: { width: 300, background: "#fff", color: "#1f2937", borderRadius: 14, padding: 22, textAlign: "center", boxShadow: "0 10px 30px rgba(0,0,0,.5)" },
  btn: { padding: "10px 18px", border: 0, borderRadius: 8, background: "#111827", color: "#fff", fontSize: 15, fontWeight: 600, cursor: "pointer" },
};

export default function App() {
  const [count, setCount] = useState(0);

  // show one toast right away so the result is visible on load
  useEffect(() => {
    const id = setTimeout(() => toast("My first toast"), 300);
    return () => clearTimeout(id);
  }, []);

  const show = () => {
    setCount(count + 1);
    toast(`Toast number ${count + 1}`);
  };

  return (
    <div style={S.page}>
      {/* every toast() call renders inside this Toaster */}
      <Toaster />
      <div style={S.card}>
        <h2 style={{ margin: "0 0 6px", fontSize: 18 }}>Sonner</h2>
        <p style={{ margin: "0 0 16px", color: "#6b7280", fontSize: 14 }}>Press the button for another toast.</p>
        <button style={S.btn} onClick={show}>Give me a toast</button>
      </div>
    </div>
  );
}
Ctrl/⌘ + Enter runs

Free for signed-in members, with a daily limit. Describe the change in plain words; the new code runs only in your browser.

Press "Give me a toast" several times to stack up numbered toasts. Code written by AgentGid [1]. How it works, with a screenshot →

Checked Oct 12, 2026: each example starts without errors in Chromium with sonner 2.0.8, react 19.3.0, react-dom 19.3.0. Needs WebGL.

Sources

  1. Sonner README (GitHub)
  2. Docs: getting-started
  3. Sonner website

Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.

Building something with Sonner? Ask AgentGid →