DocumentationToasts
Toasts
Give every action a clear answer.
Getting started
Install the package
Use React 19 and import the package stylesheet once in your app’s global CSS. The bundled styles are built for Tailwind CSS 4.
bun add @rentnerkev/toasts@import '@rentnerkev/toasts/tailwind.css';Typed toast actions#
New in 3.9.0: action.label is application-provided button text; onClick has the signature (id: ToastId) => void | PromiseLike<void>, not a browser event callback. The toast dismisses after a successful callback by default (dismissOnSuccess: true). Set dismissOnSuccess: false to retain it. A throw or rejection keeps the toast and calls the optional onError(error, id), which can also be asynchronous; failures from either callback are contained. The normal dismissal timer resumes afterward.
import { toast } from '@rentnerkev/toasts'
import type { ToastAction } from '@rentnerkev/toasts'
export function showUndo(restore: () => Promise<void>) {
const action: ToastAction = {
label: 'Undo',
onClick: async (id) => {
await restore()
console.info('Undo completed', id)
},
onError: (error, id) => {
toast.update(id, { content: 'Undo failed. Try again.' })
console.error(error)
},
}
return toast.success('Item removed', { duration: 8000, action })
}Replace or remove an action#
toast.update(id, { action }) adds or replaces a button on an existing toast. Omit action or pass undefined to preserve it; action: null removes it. An action-only update preserves timing unless duration is supplied. Completion of an older pending action does not dismiss a replacement action. Use the ToastId returned by the same store API.
import { toast } from '@rentnerkev/toasts'
export function attachRetry(retry: () => Promise<void>) {
const id = toast.error('Upload failed', { duration: 0 })
toast.update(id, {
action: {
label: 'Retry',
onClick: retry,
dismissOnSuccess: false,
onError: (_error, toastId) => {
toast.update(toastId, { content: 'Retry failed. Try again.' })
},
},
})
return () => toast.update(id, { action: null })
}Actions in promise results#
loading content options and resolved success/error content options can each include action. Success resolvers can capture the resolved value in a callback; error options can offer an application-owned Retry. Settlement replaces the loading action, and a string or content options without action clears it. The original task is not automatically retried by clicking a button.
import { toast } from '@rentnerkev/toasts'
export function saveWithActions(
save: () => Promise<{ name: string }>,
open: (name: string) => void,
retry: () => Promise<void>,
) {
return toast.promise(save, {
loading: 'Saving…',
success: (result) => ({
content: result.name + ' saved',
action: { label: 'View', onClick: () => open(result.name) },
}),
error: {
content: 'Saving failed',
duration: 0,
action: {
label: 'Retry',
onClick: retry,
onError: () => {
toast.error('Retry failed')
},
},
},
})
}Keyed toast deduplication#
New in 3.5.0: a repeated dedupeKey returns the existing visible or queued toast ID without changing its text, order or timer. Deduplication is local to a store and opt-in. Without a window the key lasts for the toast lifetime; dedupeWindow on the store or call sets milliseconds from the first creation, and zero disables it for that call. Duplicates do not extend the window. Removal, expiry, queue eviction and disposal release keys. Direct success/error/info/warning calls support this; promise message types reject dedupe options to preserve independent lifecycles.
import { createToastStore } from '@rentnerkev/toasts'
export const notifications = createToastStore({ dedupeWindow: 2000 })
export function reportConnectionFailure() {
const first = notifications.toast.error('Connection interrupted', {
dedupeKey: 'connection',
})
const duplicate = notifications.toast.error('Retry also failed', {
dedupeKey: 'connection',
})
console.log(first === duplicate) // true within the original 2000 ms window
return first
}
// Mount <ToastProvider store={notifications}> to render this store.Error normalization & toast adapter#
The new UI-free /errors entry exports resolveToastError and createToastErrorAdapter, also available from the root. The resolver reads strings and string message properties, including Error.message; empty or unreadable values and failed normalizations use fallbackMessage. normalize can return a string or ToastContentOptions with title/duration. The adapter sends an error toast through your chosen api and accepts a static or computed dedupeKey. Per-call options override normalized options. Choose user-facing messages before displaying application errors.
import { createToastStore } from '@rentnerkev/toasts'
import {
createToastErrorAdapter,
resolveToastError,
} from '@rentnerkev/toasts/errors'
export const notifications = createToastStore()
export const fallback = resolveToastError(null, {
fallbackMessage: 'Please try again',
})
export const reportError = createToastErrorAdapter({
api: notifications.toast,
dedupeKey: (_error, content) => content,
dedupeWindow: 3000,
fallbackMessage: 'Saving failed. Please try again.',
normalize: (error) =>
error instanceof Error ? 'Saving failed. Please try again.' : undefined,
})
export async function save(saveSettings: () => Promise<void>) {
try {
await saveSettings()
} catch (error) {
reportError(error, { title: 'Settings', duration: 8000 })
}
}Precise toast slots & portals#
New classNames slots cover region, root, icon, body, title, content, actions, actionButton, closeButton, closeIcon, copyButton, copyIcon, buttonOverlay, progress and link. They replace visual defaults while layout, focus and live-region semantics stay active; root replaces the full visual card, so supply its spacing, borders and colors. customDesign.wrapper shares one status style, overridden by individual status wrappers. Legacy customDesign.closeButton/copyButton still style icons. portalContainer accepts an Element, DocumentFragment or 'body'; null or undefined preserves inline SSR output. The 'body' target renders after hydration. portalClassName styles the region; portalZIndex overrides --rentner-toast-z (99999). Keep the target stable.
import { ToastProvider, useToast } from '@rentnerkev/toasts'
function Notify() {
const toast = useToast()
return (
<button type="button" onClick={() => toast.info('Packed with care')}>
Notify
</button>
)
}
export default function Notifications({
container,
}: {
container?: Element | DocumentFragment | null
}) {
return (
<ToastProvider
customDesign={{
wrapper: 'border-slate-300 bg-white text-slate-900',
}}
classNames={{
content: 'text-sm text-slate-700',
closeButton: 'rounded-md bg-slate-100 p-2',
closeIcon: 'text-slate-700',
}}
portalContainer={container}
portalClassName="font-sans"
portalZIndex={12000}
>
<Notify />
</ToastProvider>
)
}Local AI helpers: metadata & guides#
Import the /ai entry in a local Node.js or Bun script. These synchronous, read-only helpers use node:fs to read the installed package without importing its UI. getPackageInfo() returns PackageInfo, including the installed version, public exports and peer dependencies. getPackageDocumentation() returns a PackageDocument with path and content; its default is usage, and readme selects README.md. Only these two packaged documents are accepted. Results describe your installed version, which can differ from this website.
import { getPackageDocumentation, getPackageInfo } from '@rentnerkev/toasts/ai'
import type { PackageDocument, PackageInfo } from '@rentnerkev/toasts/ai'
const info: PackageInfo = getPackageInfo()
const usage: PackageDocument = getPackageDocumentation()
const readme = getPackageDocumentation('readme')
console.log(info.name, info.version, info.exports, info.peerDependencies)
console.log(usage.path, usage.content)
console.log(readme.path, readme.content)Local AI helpers: public declarations#
getPackageApi() returns PackageApi with package, installed version, selected subpaths and declarations as PackageDocument objects. It reads public typed entries and their local declaration dependencies; /ai itself is excluded. Use subpath such as . or ./types to select a public entry. symbol validates that a name is exported by the selected entry; it does not trim declaration files to that symbol. Unknown subpaths, invalid names and names not exported by the selected entry throw errors. Callers cannot provide arbitrary file paths.
import { getPackageApi } from '@rentnerkev/toasts/ai'
import type { PackageApi } from '@rentnerkev/toasts/ai'
const api: PackageApi = getPackageApi()
const selected = getPackageApi({ subpath: '.', symbol: 'toast' })
console.log(api.package, api.version, api.subpaths)
for (const declaration of selected.declarations) {
console.log(declaration.path, declaration.content)
}Local AI helpers: search & examples#
searchPackageDocumentation(query) searches README.md and docs/usage.md using a trimmed, case-insensitive literal query. It returns PackageSearchMatch objects with path, a one-based line number and matching text; an empty query returns an empty array. getPackageExamples() returns every fenced code block from the installed usage guide as a PackageExample with language and code. These helpers return text for your own tools; they do not execute examples or contact an AI service.
import { getPackageExamples, searchPackageDocumentation } from '@rentnerkev/toasts/ai'
import type { PackageExample, PackageSearchMatch } from '@rentnerkev/toasts/ai'
const matches: PackageSearchMatch[] = searchPackageDocumentation('toast')
const examples: PackageExample[] = getPackageExamples()
for (const match of matches) {
console.log(match.path, match.line, match.text)
}
for (const example of examples) {
console.log(example.language, example.code)
}Queued timer policy#
pauseWhenQueued defaults to true. Set it to false in createToastStore or either provider to let timed notifications expire while queued, including direct store.toast and global toast calls using that store. It is also part of ToastDefaults: configureToastDefaults can change it, getToastDefaults reads it and restoreToastDefaults restores it. Provider defaults apply store-wide; the most recently mounted provider defining a field wins, and unmounting restores the remaining provider or store value. Duration 0 stays persistent; hover and focus still pause timers.
import { createToastStore, ToastProvider } from '@rentnerkev/toasts'
const notifications = createToastStore({ pauseWhenQueued: false })
export function temporarilyPauseQueue() {
const previous = notifications.configureToastDefaults({ pauseWhenQueued: true })
notifications.restoreToastDefaults(previous)
}
export default function App() {
return (
<ToastProvider store={notifications} pauseWhenQueued={false} maxVisibleToasts={1}>
<button type="button" onClick={() => {
notifications.toast.info('First update', { duration: 4000 })
notifications.toast.info('Latest update', { duration: 8000 })
}}>
Show updates
</button>
</ToastProvider>
)
}Body portals & Radix focus scope#
Set portalContainer to 'body' for a global document.body portal without reading document in application render code. The surface is omitted on the server and appears after hydration; null or undefined keeps inline rendering. Place the prop-free ToastFocusScopeBranch inside each Radix Dialog.Content that should allow keyboard focus on global toast links and close/copy actions. Exported from the root and /radix, it registers the mounted toast regions with the Radix focus scope, including regions added later. Keep duration: 0 for links that need a deliberate user action. The branch adds no visible UI and does not configure portal placement or stacking. Radix integrations need the required @radix-ui/react-focus-scope ^1.3.1 peer and a compatible shared version with the dialog. When a toast containing focus unmounts, focus returns to the previously focused element outside its region if that element is still connected.
import * as Dialog from '@radix-ui/react-dialog'
import { ToastProvider, useToast } from '@rentnerkev/toasts'
import { ToastFocusScopeBranch } from '@rentnerkev/toasts/radix'
function SettingsDialog() {
const toast = useToast()
return (
<Dialog.Root>
<Dialog.Trigger>Settings</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Overlay />
<Dialog.Content>
<ToastFocusScopeBranch />
<Dialog.Title>Package settings</Dialog.Title>
<Dialog.Description>Save and review the result.</Dialog.Description>
<button type="button" onClick={() => toast.info(
'Open [the report](https://example.com/report).',
{ duration: 0 },
)}>Save</button>
<Dialog.Close>Close settings</Dialog.Close>
</Dialog.Content>
</Dialog.Portal>
</Dialog.Root>
)
}
export default function App() {
return <ToastProvider portalContainer="body"><SettingsDialog /></ToastProvider>
}Position & notification motion#
Since 3.8.0, native Web Animations API and Pointer Events replace Motion; the motion peer is no longer required. Public imports, props, design slots and appearance stay unchanged. position controls corner placement and diagonal entrance/exit, with matching stack layout animation. Both providers preserve toast identity across updates, and the final toast completes its 300 ms exit before unmounting. The browser preference prefers-reduced-motion is observed at runtime: entrance, exit, layout and progress animations, dragging and button scale/rotation effects are disabled when requested. Timer durations and independent hover/focus pauses remain unchanged. No MotionConfig or separate animation provider prop is needed.
import { ToastProvider, useToast } from '@rentnerkev/toasts'
function NotifyButton() {
const toast = useToast()
return <button type="button" onClick={() => toast.success('Saved')}>Notify</button>
}
export default function App() {
return <ToastProvider position="top-left"><NotifyButton /></ToastProvider>
}LazyToastProvider#
LazyToastProvider is a compatibility alias of ToastProvider with identical props and synchronous behavior, available from the root and /lazy-provider. Use ToastProvider for new integrations. Both load the surface with the application and mount it when their store contains notifications: the first toast needs no extra import request or loading replacement. The /toast entry remains available for UI-free imperative code.
import { LazyToastProvider, useToast } from '@rentnerkev/toasts/lazy-provider'
function NotifyButton() {
const toast = useToast()
return <button onClick={() => toast.info('Ready')} type="button">Notify</button>
}
export default function App() {
return <LazyToastProvider><NotifyButton /></LazyToastProvider>
}Queue limits & default timing#
Stores default to a duration of 6000 ms and three visible toasts; providers default to bottom-right. maxVisibleToasts controls visibility, while maxQueuedToasts optionally caps all stored toasts, including visible ones, and evicts the oldest when exceeded. The queue limit must be a positive integer and is set when creating the store. By default, hidden queued toasts do not consume their dismissal time until visible; pauseWhenQueued: false lets queued timers expire too.
import { createToastStore } from '@rentnerkev/toasts'
export const store = createToastStore({
defaultDuration: 6000,
maxVisibleToasts: 3,
maxQueuedToasts: 20,
})
export function cleanup() {
store.dispose()
}Independent timer pause owners#
The optional fourth argument to setToastPauseReason is a stable symbol identifying the pause owner. Use it when multiple surfaces or controls pause the same toast. Clearing one owner only removes its own pause; the timer resumes after every hover and focus owner has released it. Reuse the same symbol when setting and clearing a pause.
import { createToastStore } from '@rentnerkev/toasts'
const store = createToastStore()
const owner = Symbol('preview')
const id = store.toast.info('Read the details')
store.setToastPauseReason(id, 'focus', true, owner)
store.setToastPauseReason(id, 'focus', false, owner)
store.dispose()ToastProvider#
Mount ToastProvider once around the area that sends notifications. It renders the stack and supplies configuration to descendants. position supports top-left, top-right, bottom-left and bottom-right. defaultDuration is in milliseconds; maxVisibleToasts limits the visible stack. className styles each toast card; portalClassName styles the region.
import { ToastProvider, useToast } from '@rentnerkev/toasts'
function SaveButton() {
const toast = useToast()
return (
<button onClick={() => toast.success('Saved')} type="button">
Save
</button>
)
}
export default function App() {
return (
<ToastProvider
defaultDuration={4000}
maxVisibleToasts={3}
position="top-right"
>
<SaveButton />
</ToastProvider>
)
}useToast()#
Call the hook inside a React component to get the ToastApi for its nearest provider. With a custom store, this sends messages to that store instead of the global one. Call the returned API in event handlers; do not create notifications during rendering.
import { useToast } from '@rentnerkev/toasts'
export default function Feedback() {
const notifications = useToast()
return (
<button
onClick={() => notifications.info('Checking your package')}
type="button"
>
Check
</button>
)
}toast & defaultToastStore#
The exported toast API works outside React, for example in a client-side service. It uses defaultToastStore, also available from the /toast subpath. A mounted provider using the default store displays these messages. Avoid a shared global store for request-specific notifications during server rendering.
import { toast } from '@rentnerkev/toasts'
import { defaultToastStore } from '@rentnerkev/toasts/toast'
export function announceDelivery() {
const id = toast.info('Delivery received')
return defaultToastStore.getToastSnapshot().find((item) => item.id === id)
}toast.success()#
Confirm a completed action. The first argument is the message; options accept title, duration in milliseconds, an optional action and deduplication settings. The return value is a ToastId you can use to update or dismiss this notification.
import { toast } from '@rentnerkev/toasts'
export function notify() {
return toast.success('Package saved', {
title: 'Package depot',
duration: 4000,
})
}toast.error()#
Report a failed action with a useful message. The first argument is the message; options accept title, duration in milliseconds, an optional action and deduplication settings. The return value is a ToastId you can use to update or dismiss this notification.
import { toast } from '@rentnerkev/toasts'
export function notify() {
return toast.error('Could not save the package', {
title: 'Package depot',
duration: 4000,
})
}toast.info()#
Show neutral status information. The first argument is the message; options accept title, duration in milliseconds, an optional action and deduplication settings. The return value is a ToastId you can use to update or dismiss this notification.
import { toast } from '@rentnerkev/toasts'
export function notify() {
return toast.info('A new version is available', {
title: 'Package depot',
duration: 4000,
})
}toast.warning()#
Explain a condition that needs attention. The first argument is the message; options accept title, duration in milliseconds, an optional action and deduplication settings. The return value is a ToastId you can use to update or dismiss this notification.
import { toast } from '@rentnerkev/toasts'
export function notify() {
return toast.warning('Your changes are not saved', {
title: 'Package depot',
duration: 4000,
})
}toast.dismiss()#
Close one notification using its ID. A duration of 0 keeps it open until dismissal; positive durations dismiss automatically and pause on hover or focus.
import { toast } from '@rentnerkev/toasts'
export function announceProgress() {
const id = toast.info('Packing your order', { duration: 0 })
return () => toast.dismiss(id)
}toast.dismissAll()#
Clear all notifications in the API’s store, for example after leaving a workflow.
import { toast } from '@rentnerkev/toasts'
export function finishWorkflow() {
toast.dismissAll()
}toast.update()#
Update content, title, type, duration or action without adding another notification. Set title or action to null to remove it; an omitted action preserves the current button. Returns true for an existing ID and false for a missing one. Setting duration restarts its timer.
import { toast } from '@rentnerkev/toasts'
export function markAsPacked() {
const id = toast.info('Packing', { duration: 0 })
return toast.update(id, {
content: 'Packed',
type: 'success',
duration: 3000,
})
}toast.promise()#
Track a promise or a function returning a promise with one evolving toast. loading stays visible while the task runs; success receives its resolved value, and error receives the rejection. Result messages accept strings, content options or resolvers. Content options can include action; each settlement replaces the loading action, clearing it when omitted. The returned promise preserves the original result or rejection, so handle errors as usual.
import { toast } from '@rentnerkev/toasts'
export async function savePackage() {
try {
return await toast.promise(Promise.resolve({ name: 'Tooltips' }), {
loading: 'Saving…',
success: (result) => result.name + ' saved',
error: 'Saving failed',
})
} catch (error) {
console.error(error)
return undefined
}
}createToastStore()#
Create an independent notification store with defaultDuration and maxVisibleToasts. Pass it as store to ToastProvider; useToast then selects its API. Keep the instance stable and dispose it when you own its lifecycle. store.toast exposes all convenience methods documented above.
import { useEffect, useState } from 'react'
import { createToastStore, ToastProvider } from '@rentnerkev/toasts'
export default function Notifications() {
const [store] = useState(() => createToastStore({ defaultDuration: 5000 }))
useEffect(() => () => store.dispose(), [store])
return (
<ToastProvider store={store}>
<button onClick={() => store.toast.success('Ready')} type="button">
Notify
</button>
</ToastProvider>
)
}createToastApi()#
The /toast subpath exposes the adapter used to construct a ToastApi from store operations. Usually createToastStore already gives you store.toast; use this lower-level adapter when integrating compatible store operations of your own.
import { createToastApi, createToastStore } from '@rentnerkev/toasts/toast'
const store = createToastStore()
const notifications = createToastApi(store)
notifications.success('Adapter connected')
store.dispose()store.getToastDefaults()#
Read the current duration and maxVisibleToasts without changing the store.
import { createToastStore } from '@rentnerkev/toasts'
const store = createToastStore({ defaultDuration: 4000 })
export const defaults = store.getToastDefaults()
store.dispose()store.configureToastDefaults()#
Apply a partial set of defaults. The return value contains the previous defaults, so temporary configuration can be restored.
import { createToastStore } from '@rentnerkev/toasts'
const store = createToastStore()
export const previous = store.configureToastDefaults({
duration: 6000,
maxVisibleToasts: 5,
})
store.dispose()store.restoreToastDefaults()#
Restore a complete ToastDefaults object, for example after a temporary override.
import { createToastStore } from '@rentnerkev/toasts'
const store = createToastStore()
const previous = store.configureToastDefaults({ duration: 8000 })
store.restoreToastDefaults(previous)
store.dispose()store.subscribeToToasts()#
Subscribe to changes. The returned function unsubscribes your listener; read the latest data with getToastSnapshot inside the callback.
import { createToastStore } from '@rentnerkev/toasts'
const store = createToastStore()
const unsubscribe = store.subscribeToToasts(() => {
console.log(store.getToastSnapshot())
})
store.toast.info('A delivery arrived')
unsubscribe()
store.dispose()store.getToastSnapshot()#
Read the current array of toast records, including IDs, content, type, duration and remaining time. Treat the snapshot as read-only; change records through the store methods.
import { createToastStore } from '@rentnerkev/toasts'
const store = createToastStore()
store.toast.success('Ready', { duration: 0 })
export const snapshot = store.getToastSnapshot()
store.dispose()store.createToast()#
The low-level creation method accepts content, an optional title, type and duration in that order, then an optional fifth options object with dedupeKey, dedupeWindow and action. It returns the toast ID. store.toast offers the named convenience methods.
import { createToastStore } from '@rentnerkev/toasts'
const store = createToastStore()
export const id = store.createToast('Delivery ready', 'Depot', 'info', 0)
store.dispose()store.updateToast()#
Update a toast by ID. Returns false if the record no longer exists; passing a new duration resets its timer.
import { createToastStore } from '@rentnerkev/toasts'
const store = createToastStore()
const id = store.createToast('Packing', undefined, 'info', 0)
export const updated = store.updateToast(id, {
content: 'Packed',
type: 'success',
})
store.dispose()store.removeToast()#
Remove one toast and cancel its timer. Removing an unknown ID has no effect.
import { createToastStore } from '@rentnerkev/toasts'
const store = createToastStore()
const id = store.toast.info('Temporary note')
store.removeToast(id)
store.dispose()store.setToastPauseReason()#
Pause or resume a timer for hover or focus. Both reasons are tracked independently, so clearing hover does not resume a toast that still has focus. The built-in UI handles these reasons automatically.
import { createToastStore } from '@rentnerkev/toasts'
const store = createToastStore()
const id = store.toast.info('Read this first')
store.setToastPauseReason(id, 'focus', true)
store.setToastPauseReason(id, 'focus', false)
store.dispose()store.clearAllToasts()#
Remove all toast records and their timers while keeping the store and its subscriptions usable.
import { createToastStore } from '@rentnerkev/toasts'
const store = createToastStore()
store.toast.info('Temporary')
store.clearAllToasts()
store.dispose()store.dispose()#
Clean up a store you own when its lifecycle ends. This clears records, timers and subscriptions. Create stores per server request or component instance when isolation is needed.
import { createToastStore } from '@rentnerkev/toasts'
export function createNotifications() {
const store = createToastStore()
return { toast: store.toast, cleanup: () => store.dispose() }
}Translations & resolveToastMessages()#
locale selects en or de. messages overrides the live-region label, close button and error-copy labels. resolveToastMessages merges overrides with the locale catalog; toastMessageCatalog exposes the bundled translations. Notifications can include links; error notifications offer a copy action, and hover/focus pause the dismissal timer.
import {
resolveToastMessages,
toastMessageCatalog,
ToastProvider,
} from '@rentnerkev/toasts'
const messages = resolveToastMessages('en', {
closeNotification: 'Close this message',
regionLabel: toastMessageCatalog.en.regionLabel,
})
export default function LocalizedNotifications() {
return (
<ToastProvider locale="en" messages={messages}>
<main>Depot</main>
</ToastProvider>
)
}Custom design#
Style each notification type with its Wrapper, Icon and Progress slots, such as successWrapper, errorIcon or warningProgress. titleText, contentText, closeButton, copyButton and linkText cover shared elements. Set customDesign on the provider and import the package Tailwind stylesheet once.
import { ToastProvider } from '@rentnerkev/toasts'
import type { ToastCustomDesign } from '@rentnerkev/toasts'
const design: ToastCustomDesign = {
successWrapper: 'border-2 border-emerald-700 bg-emerald-50',
errorWrapper: 'border-2 border-red-700 bg-red-50',
titleText: 'font-bold text-stone-900',
contentText: 'text-stone-700',
}
export default function StyledNotifications() {
return (
<ToastProvider customDesign={design}>
<main>Depot</main>
</ToastProvider>
)
}Docs for your AI tools
Connect a compatible MCP client to read package APIs, guides and examples. Public access, no account or API key required.
Remote access is optional: add this public URL yourself to your MCP client. Clients use Streamable HTTP; the configuration format may vary. The local package /ai helpers read the installed version in Node.js or Bun and never connect to this server automatically.
{
"mcpServers": {
"rentnerPackages": {
"url": "https://packages.rentner.dev/mcp"
}
}
}Tools: list_packages, read_package_docs, read_package_api, read_package_examples and search_package_docs.
TypeScript / v3.9.0
API & types
Published signatures, props and types for this version. Expand an entry to inspect its definition and available import paths.
ToastFocusScopeBranchfunction
@rentnerkev/toasts@rentnerkev/toasts/radix
export function ToastFocusScopeBranch({ active, }?: ToastFocusScopeBranchProps): import("react").JSX.ElementToastProviderfunction
@rentnerkev/toasts@rentnerkev/toasts/lazy-provider
export function ToastProvider({ children, ...props }: ToastProviderProps): import("react").JSX.ElementLazyToastProviderconst
@rentnerkev/toasts@rentnerkev/toasts/lazy-provider
export const LazyToastProvider: typeof ToastProvidercreateToastStorefunction
@rentnerkev/toasts@rentnerkev/toasts/toast
export function createToastStore(options?: ToastStoreOptions): ToastStoretoastconst
@rentnerkev/toasts@rentnerkev/toasts/toast
export const toast: ToastApiuseToastfunction
@rentnerkev/toasts@rentnerkev/toasts/lazy-provider
export function useToast(): ToastApiresolveToastMessagesfunction
@rentnerkev/toasts@rentnerkev/toasts/messages
export function resolveToastMessages(locale?: ToastLocale, messages?: Partial<ToastMessages>): ToastMessagestoastMessageCatalogconst
@rentnerkev/toasts
export const toastMessageCatalog: Record<ToastLocale, ToastMessages>ToastActioninterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastAction {
readonly label: string
readonly onClick: (id: ToastId) => void | PromiseLike<void>
/** Dismiss after a successful callback. Defaults to true errors keep the toast. */
readonly dismissOnSuccess?: boolean
/** Receives callback failures. Errors from this handler are also contained. */
readonly onError?: (error: unknown, id: ToastId) => void | PromiseLike<void>
}ToastApiinterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastApi {
success: (content: string, options?: ToastOptions) => ToastId
error: (content: string, options?: ToastOptions) => ToastId
info: (content: string, options?: ToastOptions) => ToastId
warning: (content: string, options?: ToastOptions) => ToastId
dismiss: (id: ToastId) => void
dismissAll: () => void
update: (id: ToastId, options: ToastUpdateOptions) => boolean
promise: <T>(input: ToastPromiseInput<T>, options: ToastPromiseOptions<T>) => Promise<T>
}ToastContentOptionsinterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastContentOptions extends Omit<ToastOptions, keyof ToastDedupeOptions> {
content: string
}ToastIdtype
@rentnerkev/toasts@rentnerkev/toasts/types
export type ToastId = stringToastOptionsinterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastOptions extends ToastDedupeOptions {
action?: ToastAction
title?: string
duration?: number
}ToastPositiontype
@rentnerkev/toasts@rentnerkev/toasts/types
export type ToastPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'ToastPromiseContentOptionstype
@rentnerkev/toasts@rentnerkev/toasts/types
export type ToastPromiseContentOptions = Omit<ToastContentOptions, keyof ToastDedupeOptions> & {
dedupeKey?: never
dedupeWindow?: never
}ToastPromiseInputtype
@rentnerkev/toasts@rentnerkev/toasts/types
export type ToastPromiseInput<T> = PromiseLike<T> | (() => PromiseLike<T>)ToastPromiseLoadingMessagetype
@rentnerkev/toasts@rentnerkev/toasts/types
export type ToastPromiseLoadingMessage = string | Omit<ToastPromiseContentOptions, 'duration'>ToastPromiseMessagetype
@rentnerkev/toasts@rentnerkev/toasts/types
export type ToastPromiseMessage<T> = string | ToastPromiseContentOptions | ((value: T) => string | ToastPromiseContentOptions)ToastPromiseOptionsinterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastPromiseOptions<T> {
loading: ToastPromiseLoadingMessage
success: ToastPromiseMessage<T>
error: ToastPromiseMessage<unknown>
duration?: number
}ToastDefaultsinterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastDefaults {
readonly duration: number
readonly maxVisibleToasts: number
/** Pause timers outside the visible window. Defaults to true false expires queued toasts too. */
readonly pauseWhenQueued?: boolean
}ToastDedupeOptionsinterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastDedupeOptions {
/** Reuse an active notification with this key instead of adding a duplicate. */
dedupeKey?: string
/** Milliseconds from creation defaults to the store window (active lifetime). Zero disables deduplication. */
dedupeWindow?: number
}ToastPauseReasontype
@rentnerkev/toasts@rentnerkev/toasts/types
export type ToastPauseReason = 'hover' | 'focus'ToastStoreinterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastStore {
readonly toast: ToastApi
getToastDefaults: () => ToastDefaults
configureToastDefaults: (defaults: Partial<ToastDefaults>) => ToastDefaults
restoreToastDefaults: (defaults: ToastDefaults) => void
subscribeToToasts: (listener: () => void) => () => void
getToastSnapshot: () => readonly Toast[]
createToast: (content: string, title?: string, type?: ToastType, duration?: number, options?: ToastDedupeOptions & Pick<ToastOptions, 'action'>) => ToastId
updateToast: (id: ToastId, options: ToastUpdateOptions) => boolean
removeToast: (id: ToastId) => void
setToastPauseReason: (id: ToastId, reason: ToastPauseReason, paused: boolean, owner?: symbol) => void
clearAllToasts: () => void
dispose: () => void
}ToastStoreOptionsinterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastStoreOptions {
/** Default deduplication window for keyed notifications. Defaults to Infinity. */
dedupeWindow?: number
defaultDuration?: number
maxVisibleToasts?: number
/** Defaults to true. Set false to count down queued notifications as well. */
pauseWhenQueued?: boolean
/** Optional total queue limit, including visible toasts. Evicts the oldest. */
maxQueuedToasts?: number
}ToastTypetype
@rentnerkev/toasts@rentnerkev/toasts/types
export type ToastType = 'success' | 'error' | 'info' | 'warning'ToastUpdateOptionsinterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastUpdateOptions {
/** Undefined preserves the action null removes it. */
action?: ToastAction | null
content?: string
title?: string | null
type?: ToastType
duration?: number
}ToastLocaletype
@rentnerkev/toasts@rentnerkev/toasts/messages
export type ToastLocale = 'de' | 'en'ToastMessagesinterface
@rentnerkev/toasts@rentnerkev/toasts/messages
export interface ToastMessages {
regionLabel: string
closeNotification: string
copyError: string
errorCopied: string
}ToastCustomDesigninterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastCustomDesign {
/** Shared status appearance a specific status wrapper takes precedence. */
wrapper?: string
successWrapper?: string
errorWrapper?: string
infoWrapper?: string
warningWrapper?: string
successIcon?: string
errorIcon?: string
infoIcon?: string
warningIcon?: string
successProgress?: string
errorProgress?: string
infoProgress?: string
warningProgress?: string
titleText?: string
contentText?: string
/** Legacy icon classes. Prefer classNames.closeIcon for new integrations. */
closeButton?: string
/** Legacy icon classes. Prefer classNames.copyIcon for new integrations. */
copyButton?: string
linkText?: string
}ToastClassNamesinterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastClassNames {
region?: string
root?: string
icon?: string
body?: string
title?: string
content?: string
actionButton?: string
actions?: string
closeButton?: string
closeIcon?: string
copyButton?: string
copyIcon?: string
buttonOverlay?: string
progress?: string
link?: string
}ToastPortalOptionsinterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastPortalOptions {
/** Undefined/null renders inline. 'body' creates a global portal after hydration. An active ToastFocusScopeBranch temporarily hosts surfaces outside its dialog. */
portalContainer?: Element | DocumentFragment | 'body' | null
portalClassName?: string
portalZIndex?: number
}ToastProviderPropsinterface
@rentnerkev/toasts@rentnerkev/toasts/types@rentnerkev/toasts/lazy-provider
export interface ToastProviderProps extends ToastPortalOptions {
children: ReactNode
store?: ToastStore
customDesign?: ToastCustomDesign
classNames?: ToastClassNames
position?: ToastPosition
className?: string
locale?: ToastLocale
messages?: Partial<ToastMessages>
defaultDuration?: number
maxVisibleToasts?: number
/** Store-wide queue timer policy, including direct toast.* calls. */
pauseWhenQueued?: boolean
}ToastFocusScopeBranchPropsinterface
@rentnerkev/toasts@rentnerkev/toasts/types
export interface ToastFocusScopeBranchProps {
/** Disable a mounted host when a custom dialog has no native open/hidden state. */
active?: boolean
}createToastErrorAdapterfunction
@rentnerkev/toasts@rentnerkev/toasts/errors
export function createToastErrorAdapter({ api, dedupeKey, dedupeWindow, ...options }?: ToastErrorAdapterOptions): ToastErrorAdapterresolveToastErrorfunction
@rentnerkev/toasts@rentnerkev/toasts/errors
export function resolveToastError(error: unknown, { fallbackMessage, normalize, }?: ToastErrorOptions): ToastContentOptionsToastErrorAdaptertype
@rentnerkev/toasts@rentnerkev/toasts/types@rentnerkev/toasts/errors
export type ToastErrorAdapter = (error: unknown, options?: ToastOptions) => ToastIdToastErrorAdapterOptionsinterface
@rentnerkev/toasts@rentnerkev/toasts/types@rentnerkev/toasts/errors
export interface ToastErrorAdapterOptions extends ToastErrorOptions {
api?: Pick<ToastApi, 'error'>
dedupeKey?: string | ((error: unknown, content: string) => string | undefined)
dedupeWindow?: number
}ToastErrorOptionsinterface
@rentnerkev/toasts@rentnerkev/toasts/types@rentnerkev/toasts/errors
export interface ToastErrorOptions {
fallbackMessage?: string
normalize?: (error: unknown) => string | ToastContentOptions | null | undefined
}createToastApifunction
@rentnerkev/toasts/toast
export function createToastApi(store: ToastApiStore): ToastApidefaultToastStoreconst
@rentnerkev/toasts/toast
export const defaultToastStore: ToastStoreToastinterface
@rentnerkev/toasts/types
export interface Toast {
readonly id: ToastId
readonly content: string
readonly title?: string
readonly action?: ToastAction
readonly type: ToastType
readonly duration: number
readonly createdAt: number
readonly remaining: number
readonly timerStartedAt?: number
}CustomToastPropsinterface
@rentnerkev/toasts/types
export interface CustomToastProps {
toast: Toast
position: ToastPosition
onRemove: (id: string) => void
customDesign?: ToastCustomDesign
classNames?: ToastClassNames
className?: string
messages: ToastMessages
}ToastPropsinterface
@rentnerkev/toasts/types
export interface ToastProps extends ToastPortalOptions {
customDesign?: ToastCustomDesign
classNames?: ToastClassNames
position: ToastPosition
className?: string
locale?: ToastLocale
messages?: Partial<ToastMessages>
}UseCustomToastLogicResultinterface
@rentnerkev/toasts/types
export interface UseCustomToastLogicResult {
state: {
actionPending?: boolean
copied: boolean
wrapperClasses: string
toastIcon: ReactNode
progressClasses: string
parsedTitle: ReactNode
parsedContent: ReactNode
startingScale: number
progressDuration: number
isTimerRunning: boolean
initialAnimation: ReturnType<typeof getToastInitialAnimation>
animate: typeof toastAnimate
exitAnimation: ReturnType<typeof getToastExitAnimation>
transition: typeof toastTransition
dragAnimation: typeof toastDragAnimation
dragEnabled: boolean
}
handler: {
handleAction?: () => void
handleCopyError: (e: MouseEvent<HTMLButtonElement>) => void
handleDragEnd: ToastDragEndHandler
handleMouseEnter: () => void
handleMouseLeave: () => void
handleFocus: (event: FocusEvent<HTMLDivElement>) => void
handleBlur: (event: FocusEvent<HTMLDivElement>) => void
}
}PackageInfointerface
@rentnerkev/toasts/ai
export interface PackageInfo {
name: string
version: string
description: string
license: string
homepage: string
repository: {
type: string
url: string
}
exports: Record<string, string | {
types?: string
import?: string
default?: string
}>
peerDependencies: Record<string, string>
}PackageDocumentinterface
@rentnerkev/toasts/ai
export interface PackageDocument {
path: string
content: string
}PackageApiinterface
@rentnerkev/toasts/ai
export interface PackageApi {
package: string
version: string
subpaths: Record<string, string>
declarations: PackageDocument[]
}PackageSearchMatchinterface
@rentnerkev/toasts/ai
export interface PackageSearchMatch {
path: string
line: number
text: string
}PackageExampleinterface
@rentnerkev/toasts/ai
export interface PackageExample {
language: string
code: string
}getPackageInfofunction
@rentnerkev/toasts/ai
export function getPackageInfo(): PackageInfogetPackageDocumentationfunction
@rentnerkev/toasts/ai
export function getPackageDocumentation(document?: 'readme' | 'usage'): PackageDocumentgetPackageApifunction
@rentnerkev/toasts/ai
export function getPackageApi(options?: {
subpath?: string
symbol?: string
}): PackageApisearchPackageDocumentationfunction
@rentnerkev/toasts/ai
export function searchPackageDocumentation(query: string): PackageSearchMatch[]getPackageExamplesfunction
@rentnerkev/toasts/ai
export function getPackageExamples(): PackageExample[]