Skip to main content
Version: 2.0 (Latest)

toast API

The toast used to show and manage toast notifications.

import { toast } from "d9-toast";

Available Methods

MethodDescription
toast(msg, options)Show default toast
toast.success(msg, options)Show success toast
toast.error(msg, options)Show error toast
toast.info(msg, options)Show info toast
toast.warning(msg, options)Show warning toast
toast.promise(promise, messages, options)Promise-based toast
toast.dismiss(id)Remove toast
toast.dismissAll()Clear all toasts

toast(message, options?)

toast("Simple notification");

toast.success(message, options?)

toast.success("Profile updated");

toast.error(message, options?)

toast.error("Something went wrong");

toast.promise(promise, messages, options?)

toast.promise(
fetch("/api/save"),
{
loading: "Saving...",
success: "Saved!",
error: "Failed",
}
);

✔ Auto loading ✔ Auto resolve / reject ✔ Returns original promise