# react-hot-toast alternative with spring physics

If you like react-hot-toast’s small API but want toasts that move on springs and change in place, Boing keeps the familiar calls (`toast.success`, `toast.error`, `toast.promise`, `<Toaster />`) and swaps fixed-time slides for physics.

## What stays the same

Both libraries use one `<Toaster />` and a `toast` object you import anywhere, with no provider. The everyday calls read almost the same:

```ts
import { toast } from 'react-boing';

toast.success('Settings saved');
toast.error('Could not save settings');

await toast.promise(saveSettings(values), {
  loading: 'Saving…',
  success: 'Settings saved',
  error: (err) => `Save failed: ${String(err)}`,
});
```

## What changes

- **Motion.** Toasts enter, resize and leave on springs, so a toast interrupted mid-move keeps going smoothly. The [animation guide](https://boing.aayushbharti.in/react-toast-animation/) explains how.
- **One toast at a time.** A new message morphs the visible toast instead of adding another one. Repeats of the same message show a `×2` counter.
- **Undo built in.** An `action` whose `onClick` returns a patch turns the toast into a confirmation, as in the [undo guide](https://boing.aayushbharti.in/undo-toast/).
- **Timing by type.** Success, warning and info close after 5 seconds; errors, loading toasts and toasts with buttons stay until handled.
- **Text only.** There is no custom JSX toast. You get a title, description, meta text, image, progress bar and buttons.

## How do react-hot-toast calls translate?

| react-hot-toast | Boing |
| --- | --- |
| `import toast, { Toaster } from 'react-hot-toast'` | `import { toast, Toaster } from 'react-boing'` |
| `toast('Hello')` | `toast.info('Hello')` |
| `toast.success` / `toast.error` / `toast.loading` | Same names, plus `toast.warning` and `toast.info` |
| `toast.promise(p, { loading, success, error })` | Same shape |
| `toast.success('Done', { id })` to replace a toast | `toast.update(id, { type: 'success', title: 'Done' })` |
| `toast.dismiss(id?)` | `toast.dismiss(id?)` |
| `toast.remove(id?)` | `toast.dismiss(id, { immediate: true })` |
| `toast.custom(…)` and JSX messages | No equivalent |
| Headless hook for your own UI | `toast.subscribe` and `toast.getState` with `useSyncExternalStore` |

`duration` (in milliseconds) and `id` carry over as options. Boing adds `description`, `meta`, `image`, `progress` and two button slots; the full list is in [toast options](https://boing.aayushbharti.in/docs/#options).

## When react-hot-toast is the better fit

Stay with react-hot-toast if you render custom components inside toasts, build your own toast UI on its headless hook, or simply want several toasts visible at once. Those are things it does well and Boing does not try to do.

## Frequently asked questions

### Can I swap react-hot-toast for Boing without changing my calls?

Close but not exact. `toast.success`, `toast.error`, `toast.loading`, `toast.promise` and `toast.dismiss` carry over; bare `toast()` calls and custom JSX toasts need changing.

### Can I keep my toast.promise calls?

Yes. The messages object has the same `loading`, `success` and `error` keys, and success and error can be functions of the result or error.

### Does Boing need an animation library?

No. It has no runtime dependencies. The springs are solved in the library and played with the Web Animations API and CSS.

### Can I turn the spring bounce down?

Yes. Pass `springs` to `toast.configure` with a higher `damping` for `enter`, `morph` or `stack`.

## Related guides

- [Sonner alternative that shows one toast at a time](https://boing.aayushbharti.in/sonner-alternative/): One toast that morphs instead of a stack.
- [React toast animation](https://boing.aayushbharti.in/react-toast-animation/): Springs, morphing in place and reduced motion.
- [React toast notifications](https://boing.aayushbharti.in/react-toast/): One component and one function call.
- [Boing docs](https://boing.aayushbharti.in/docs/): Setup, options, styling, sound and accessibility.

Source: https://boing.aayushbharti.in/react-hot-toast-alternative/
