Skip to content
@pyreon/toast
fundamentals · feedback

toast('Saved'). From a store, a loader, anywhere.

Mount one <Toaster />, then call toast() from components, stores, route loaders or a plain fetch wrapper. No provider, no hook, no context. Promise toasts, actions, a countdown that waits while the user reads, and the right screen-reader role for each type come with it.

bun add @pyreon/toast
Documentation
setup
one <Toaster />Then toast() from any module.
vs react-hot-toast
cold create 3.3× faster2.5× vs sonner. One run, bun/JavaScriptCore.
screen readers
role="alert" for errorsrole="status" for info and success.
iOS and Android
toast() + <Toaster>Experimental. A native overlay in the next release; promise, update and JSX content stay web.
toast() from anywhere lands in one Toaster Schematic: a store calls toast.success('Saved'), a route loader calls toast('Copied') and a fetch wrapper calls toast.error('Upload failed'). Each one travels to the single <Toaster /> and stacks there; the error toast carries role="alert", the others role="status". Each leaves when its countdown runs out. ONE <TOASTER /> · TOAST() FROM ANY MODULE a storetoast.success('Saved')a route loadertoast('Copied')a fetch wrappertoast.error('Upload failed') <Toaster position="top-right" /> Savedrole="status" Copiedrole="status" Upload failedrole="alert" no provider, no hook, no context · hover pauses every countdown
  • 3.3× faster cold toast creation than react-hot-toast (2.5× vs sonner)BENCHMARKS.md §10, toast row · overnight run, one run, bun/JavaScriptCore
  • 2.5–3.8× faster headless store operations than react-hot-toastBENCHMARKS.md §10, toast row · one run
  • 3 independent pauses: hover, keyboard focus, hidden tabpackages/fundamentals/toast/src/toast.ts pause sources; .agents/guides/fundamentals/references/toast.md

synthetic · author-run · M3 Max · record of 2026-11-05

Every result, including where we lose →
why teams pick it

The toast system you keep rebuilding, finished.

  1. Call it where the error happens

    A store action, a route loader or an HTTP interceptor can call toast.error('Card declined') directly. Error handling stays next to the error, not threaded through a hook.

  2. Loading to done in one call

    toast.promise(upload(), { loading: 'Uploading…', success: (n) => Uploaded ${n} files, error: 'Upload failed' }) swaps the same toast in place and returns your promise.

  3. A countdown that waits for the reader

    Hovering, tabbing into a toast, or switching tabs each hold the timer. The holds are tracked separately, so releasing one does not restart the clock while another still holds it.

  4. Announced with the right urgency

    Errors and warnings use role="alert", info and success role="status", each with aria-atomic. The container sets no aria-live, so nothing is read twice.

the difference

You wrote this provider. It never paused on hover.

React, by hand

A context, an array in state, a timer per toast. No pause, no screen-reader role, and no way to call it from outside a component.

const ToastContext = createContext<(msg: string) => void>(() => {})

export function ToastProvider({ children }: { children: ReactNode }) {
  const [toasts, setToasts] = useState<{ id: number; msg: string }[]>([])
  const show = useCallback((msg: string) => {
    const id = Date.now()
    setToasts((t) => [...t, { id, msg }])
    setTimeout(() => setToasts((t) => t.filter((x) => x.id !== id)), 4000)
  }, [])
  return (
    <ToastContext.Provider value={show}>
      {children}
      <div className="toasts">
        {toasts.map((t) => <div key={t.id}>{t.msg}</div>)}
      </div>
    </ToastContext.Provider>
  )
}
with @pyreon/toast

Mount once. Call from anywhere. Pausing, roles, animation and cleanup are done.

import { toast, Toaster } from '@pyreon/toast'

const App = () => (
  <>
    <Toaster position="top-right" />
    <Routes />
  </>
)

// in a store, a loader, a fetch wrapper:
toast.success('Saved')
coming from

Coming from sonner or react-hot-toast?

The calls you know, no React.

sonner
import { Toaster, toast } from 'sonner'

toast.promise(save(), {
  loading: 'Saving…',
  success: 'Saved',
  error: 'Could not save',
})
toast.error('Card declined', {
  description: 'Try another card',
  action: { label: 'Retry', onClick: () => retry() },
})

// once, at the root of the app
<Toaster position="top-right" />
Pyreon

Same shapes for promise, description and action. sonner's collapsed stack and swipe-to-dismiss are not here; toasts list up to max (5 by default).

import { Toaster, toast } from '@pyreon/toast'

toast.promise(save(), {
  loading: 'Saving…',
  success: 'Saved',
  error: 'Could not save',
})
toast.error('Card declined', {
  description: 'Try another card',
  action: { label: 'Retry', onClick: () => retry() },
})

// once, at the root of the app
<Toaster position="top-right" />

loading, then the same id.

react-hot-toast
import toast from 'react-hot-toast'

const id = toast.loading('Uploading…')
// later
toast.success('Uploaded', { id })
Pyreon

The same split as react-hot-toast: toast.dismiss(id) plays the leave animation, toast.remove(id) removes at once.

import { toast } from '@pyreon/toast'

const id = toast.loading('Uploading…')
// later
toast.update(id, { type: 'success', message: 'Uploaded', duration: 4000 })
try it

Make some toast.

Hover the stack to pause every countdown. The demo's Toaster has max={3}: fire more and the newest three stay on screen while older ones wait behind them, coming back when a newer one leaves, unless their own countdown has run out first.

fire some toast
<Toaster position="top-right" max={3} duration={4000} />
  • in the store0
  • on screen0

Toasts appear in the top-right corner of the window. Hover or focus them to pause every countdown, including the ones waiting behind the three on screen.

benchmarks

From a cold start, toasts go in 3.3× faster than react-hot-toast.

Store operations run without a DOM, so they compare the libraries' own work. sonner only removes a dismissed toast after its mounted Toaster animates, so it sits out the headless rows; its Toaster does not render under happy-dom, so it sits out the commit row. It is measured on cold creation. The commit row is happy-dom, a JavaScript DOM: read it as relative.

vs react-hot-toast 2.6 and sonner 2.0 · bun/JavaScriptCorePyreonrival · lower is better
  • cold create vs react-hot-toast
    win3.3×
  • cold create vs sonner
    win2.5×
  • headless store ops vs react-hot-toast
    win2.5–3.8×
  • DOM commit vs react-hot-toast (happy-dom)
    win21–31×, happy-dom only
Apple M3 Max · record of 2026-11-05 · overnight run, one run · author-run, syntheticFull method, every loss →
what's included

Everything a toast needs, nothing to wire.

  • toast(message, options) Returns an id you can update or dismiss later.
  • Presets toast.success, .error, .warning, .info, and .loading, which stays until you update it.
  • toast.promise Loading, then success or error with the result or the error in the message; returns your promise.
  • toast.update(id, …) Change message, type or duration in place, without a new toast.
  • Actions { label: 'Undo', onClick: ({ dismiss }) => … } with the toast's own dismiss.
  • Rich content JSX in message, description and icon.
  • Soft and hard removal dismiss animates out (200 ms) and fires onDismiss once; remove is instant.
  • Three pause holds Hover, keyboard focus and a hidden tab, with the remaining time kept.
  • <Toaster> props position (top or bottom; left, center or right), max, gap, offset, duration.
  • Reduced motion Transitions switch off under prefers-reduced-motion: reduce.
recipes

Things to build with it.

Toast every failed request in one place

An interceptor in your HTTP layer, no component involved.

import { toast } from '@pyreon/toast'

export async function api<T>(path: string): Promise<T> {
  const res = await fetch(path)
  if (!res.ok) {
    toast.error(`Request failed (${res.status})`, {
      description: path,
      // a retry that fails toasts again; it does not hand data back to the first caller
      action: { label: 'Retry', onClick: ({ dismiss }) => { dismiss(); api(path).catch(() => {}) } },
    })
    throw new Error(`[app] ${path} → ${res.status}`)
  }
  return res.json() as Promise<T>
}
Undo instead of "Are you sure?"

Delete at once, offer Undo for five seconds, and commit only if nobody clicked it.

function removeTask(task: Task) {
  tasks.update((ts) => ts.filter((t) => t.id !== task.id))
  let undone = false
  toast('Task deleted', {
    duration: 5000,
    action: {
      label: 'Undo',
      onClick: ({ dismiss }) => {
        undone = true
        tasks.update((ts) => [...ts, task])
        dismiss()
      },
    },
    onDismiss: () => { if (!undone) void deleteOnServer(task.id) },
  })
}
api

One function, one component.

Every export has a reference page with its signature, an example and the mistakes people make with it.

call · 10
  • toast
  • toast.success
  • toast.error
  • toast.warning
  • toast.info
  • toast.loading
  • toast.promise
  • toast.update
  • toast.dismiss
  • toast.remove
render · 1
  • Toaster
types · 9
  • Toast
  • ToastOptions
  • ToastAction
  • ToastActionContext
  • ToasterProps
  • ToastPosition
  • ToastPromiseOptions
  • ToastState
  • ToastType
good to know

Good to know before you start.

Beyond max, older toasts wait unseen

The newest max toasts (5 by default) are on screen. Older ones keep their own countdown and come back when a newer one leaves, if they have not timed out. Raise max or use a dialog for messages that must be read.

One position per Toaster

position is a Toaster prop, so every toast shares it. There is no per-toast position, collapsed stack or swipe-to-dismiss.

Mount the Toaster on the client

toast() on the server is a no-op with a dev warning: a request has no screen to show it on.

Native gets the core

iOS and Android lower toast() and <Toaster> with literal options. The native overlay, with description, action and onDismiss, lands in the next release. toast.promise, toast.update, a JSX description and icons stay web and warn by name; the hover pause is web-only. Native targets are experimental.

questions

What people ask first.

Do I need a provider?

No. The store is a module-level signal. <Toaster /> renders it through a portal, and toast() works from any module once the Toaster is mounted.

Where do the speed numbers come from?

The toast row of the record: store operations against react-hot-toast 2.5–3.8×, cold creation 3.3× vs react-hot-toast and 2.5× vs sonner, one run under bun. The record also lists a 21–31× DOM-commit figure, measured under happy-dom, so we do not lead with it.

Is it accessible?

Each toast has the live-region role for its urgency and aria-atomic; the stack is a labelled region; keyboard focus pauses the countdown; dismiss and action buttons are real buttons.

Can a toast stay until the work finishes?

Yes: toast.loading('Saving…') has no timeout. toast.update(id, { type: 'success', message: 'Saved', duration: 4000 }) turns it into a normal toast, or let toast.promise do both.

Saved. (That was a toast.)

bun add @pyreon/toast
Read the toast guide