Skip to content
TrademarkTrademark
Docs
Contexts

ToastProvider

Updated: October 11, 2026
View on GitHub

The ToastProvider wraps your app to provide access to useToast, allowing any component to trigger lightweight, dismissible toast messages globally.

Simple setup

Wrap your app with ToastProvider to activate toast functionality.

Advanced setup

We recommend using a Providers component to wrap your app. You can choose to display toasts at the top or bottom based on breakpoints.

Use the useToast() hook to display notifications from anywhere in your app:

Duration and removing a toast

addToast returns the new toast's id. Pass it to removeToast to take the toast down before it times out, such as a "Saving…" toast once the save is done. Each toast stays up for its duration in milliseconds: 6000 by default, and Infinity keeps it up until it is closed. The countdown pauses while the toast is hovered or has focus, and resumes with the time that was left.

addToast and removeToast keep the same identity for the provider's lifetime, so an effect can list them as dependencies without running again each time a toast appears. There is no need to hold them in a ref.

Toaster

The ToastProvider automatically renders a <Toaster /> under the hood, passing it the current list of toasts and a removeToast handler.

API reference

useToast

Type
Default
toasts
Toast[]—
addToast
(toast: { message: ReactNode; variant: 'success' | 'danger' | 'warning' | 'info'; action?: ReactNode; duration?: number }) => string—
removeToast
(id: string) => void—

Toast

Type
Default
id
string—
variant
successdangerwarninginfo
—
message
ReactNode—
action
ReactNode—
duration
Milliseconds before it closes. Infinity keeps it up until it is closed.
number6000

ToastProvider

Type
Default
childrenrequired
React.ReactNode—
xl
topbottom
—
l
topbottom
—
m
topbottom
—
s
topbottom
—
xs
topbottom
—
Edit this page on GitHub