Toasts
NextToast exposes a small, consistent API. Most methods accept a message and optional options like description, duration, dismissible, and action.
Basic notifications
Use these for straightforward user feedback. Keep titles short and avoid repeating UI context. For example, prefer Saved over Settings saved successfully if the action is already obvious.
toast.message
Neutral message toast. Best for low-priority feedback that should not steal attention.
Click to trigger the toast. Switch to Code to copy.
toast.success
Use for completed actions: save, create, update, publish. Keep it short and affirmative.
Click to trigger the toast. Switch to Code to copy.
toast.info
Use for informational updates: new version available, background jobs started, sync scheduled.
Click to trigger the toast. Switch to Code to copy.
toast.warning
Use for recoverable problems: missing configuration, partial validation, limited access. Provide guidance in description when possible.
Click to trigger the toast. Switch to Code to copy.
toast.error
Use for failed actions. Prefer actionable error text: what failed and what to do next.
Click to trigger the toast. Switch to Code to copy.
Common options
description
Use description to add a second line of detail. This is the best place for small guidance like which setting to change, why an action failed, or what happens next.
Click to trigger the toast. Switch to Code to copy.
duration
Duration is in milliseconds. Use shorter durations for success/info and longer durations for warning/error. For loading states, prefer an infinite toast and update it later.
Click to trigger the toast. Switch to Code to copy.
dismissible
Set dismissible to false when the toast should not be manually dismissed (usually for loading or required flows). Use sparingly.
Click to trigger the toast. Switch to Code to copy.
Action button
Use action for quick, reversible operations like Undo, Retry, or View. Keep the label short and the behavior safe.
Click to trigger the toast. Switch to Code to copy.
Confirm
toast.confirm is useful for destructive actions when you want a lightweight confirmation without opening a modal. Keep the message specific.
Click to trigger the toast. Switch to Code to copy.
Loading and update
Use toast.loading when an operation has unknown duration. It returns an id. Later you can toast.update the same toast to success/error.
Click to trigger the toast. Switch to Code to copy.
Promise
toast.promise is the simplest way to handle async flows. It shows a loading toast, then swaps to success or error automatically.
Click to trigger the toast. Switch to Code to copy.
Custom
Use toast.custom when you need complete control over layout and interactions. Keep it lightweight: short text, one primary action, optional dismiss.
Click to trigger the toast. Switch to Code to copy.
Dismiss
Dismiss a single toast by id, or clear everything with toast.dismissAll(). This is useful when navigating between screens or replacing stale messages.
Click to trigger the toast. Switch to Code to copy.
Dismiss by id
Click to trigger the toast. Switch to Code to copy.
Guidelines
- Prefer
toast.promisefor async work; it reduces boilerplate and keeps state consistent. - Keep titles short. Use
descriptionfor details, next steps, or context. - Avoid stacking repeated errors. Consider
toast.dismissAll()before showing a critical toast. - Use confirm for destructive actions when a modal would be too heavy.
API References
| Prop | Type | Default | Description |
|---|---|---|---|
| description | React.ReactNode | — | Optional second line of text shown under the message. |
| duration | number | 2000 | Auto-dismiss time in milliseconds. Use Infinity to keep it open. |
| dismissible | boolean | true | Whether the toast can be dismissed manually. |
| action | { label: string; onClick: (e) => void } | — | Adds an action button (for example Undo / Retry). |
| id | string | number | auto | Optional custom id. Useful to update or dismiss a specific toast. |
Next
Continue to Configuration to learn how to set global behavior like position, rich colors, close button, and max visible.