rtm

Toast API

Reference for the toast function and its methods.

Ask ChatGPT

The toast object provides several methods to trigger notifications with different styles.

toast(message, type, duration)

The main function for showing a toast.

ParameterTypeDefaultDescription
messagestring-The message to display.
typeToastType'default'The style of the toast.
durationnumber3000Time in ms before auto-close.

Methods

toast.success(message, duration?)

Shorthand for toast(message, duration).

toast.error(message, duration?)

Shorthand for toast.error(message, duration).

toast.warning(message, duration?)

Shorthand for toast.warning(message, duration).

toast.default(message, duration?)

Shorthand for toast(message, duration).

toast.promise(promise, data, options?)

Displays a loading toast that automatically updates to success or error when the promise resolves or rejects.

ParameterTypeDescription
promisePromiseThe promise to track.
dataobjectContent for different states (see below).
optionsToastOptionsOptional configuration.

Data Object

FieldTypeDescription
loadingstringMessage to show while the promise is pending.
successstring | (data) => stringMessage or function generating message on success.
errorstring | (err) => stringMessage or function generating message on error.

Example

tsx
1import { toast } from "react-toast-msg";
2
3toast.success("Profile updated", { duration: 2000 });

How is this guide?

Last updated on March 20, 2026