# Sonner Show brief notifications with optional actions, status icons and asynchronous updates. [Interactive guide](/docs/components/sonner) · Forge 3.2.0 Use the API for your installed version. Run `npx --no-install wss3-forge api --json` inside the project. ## Implementation guidance ### When to use it Use Sonner when the app has chosen the Sonner queue or needs to track one async result from pending through completion. ### How to compose it Mount a Toaster inside ForgeProvider and import toast from wss3-forge/sonner. Feed toast.promise the operation and messages for all three outcomes. ### What to verify Resolve and reject the operation separately. Verify each outcome updates the original toast. Press Alt+T, then Tab, to reach a toast action. ## Usage ```tsx import { Toaster, toast } from 'wss3-forge/sonner' ``` - Mount one Toaster inside the application’s ForgeProvider. Import toast from wss3-forge/sonner wherever an action needs feedback. - Call toast.promise with the operation and messages for loading, success and failure. Sonner updates the original notification when the operation settles. - Set position on Toaster to move the whole stack, or pass position to an individual toast. For separate stacks, match each toast’s toasterId to its host’s id. - Press Alt+T to focus the notification stack, then Tab to reach an action such as Undo. ```tsx import type { ReactNode } from 'react' import { ForgeProvider } from 'wss3-forge' import { Toaster } from 'wss3-forge/sonner' export default function AppLayout({ children }: { children: ReactNode }) { return ( {children} ) } ``` ## Runnable examples ### Notification with undo ```tsx import { useId, useState } from 'react' import { Box, Button, Text, VStack } from 'wss3-forge' import { Toaster, toast } from 'wss3-forge/sonner' function PreviewToaster({ id }: { id: string }) { // A notification host belongs outside the trigger row's alignment and spacing. return } function EventToast() { const id = useId() const [undone, setUndone] = useState(false) function scheduleReview() { setUndone(false) toast('Review scheduled', { id, toasterId: id, description: 'Monday at 09:00', action: { label: 'Undo', onClick: () => setUndone(true) }, }) } return ( {undone && Review removed from the schedule.} ) } export default function Example() { return () } ``` ### Types ```tsx import { useId } from 'react' import { Box, Button, HStack } from 'wss3-forge' import { Toaster, toast } from 'wss3-forge/sonner' function PreviewToaster({ id }: { id: string }) { // A notification host belongs outside the trigger row's alignment and spacing. return } function NotificationTypes() { const id = useId() const options = { toasterId: id } function exportDraft() { const job = new Promise(resolve => window.setTimeout(() => resolve('Draft exported'), 700)) toast.promise(job, { ...options, loading: 'Exporting draft…', success: value => value, error: 'Export failed', }) } return ( ) } export default function Example() { return () } ``` ### Description ```tsx import { useId } from 'react' import { Box, Button } from 'wss3-forge' import { Toaster, toast } from 'wss3-forge/sonner' function PreviewToaster({ id }: { id: string }) { // A notification host belongs outside the trigger row's alignment and spacing. return } function ToastWithDescription() { const id = useId() return ( <> ) } export default function Example() { return () } ``` ### Position ```tsx import { useId } from 'react' import { Box, Button, HStack } from 'wss3-forge' import { Toaster, toast, type ToasterProps } from 'wss3-forge/sonner' function PreviewToaster({ id }: { id: string }) { // A notification host belongs outside the trigger row's alignment and spacing. return } function ToastPositions() { const id = useId() const positions: NonNullable[] = [ 'top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right', ] return ( {positions.map(position => ( ))} ) } export default function Example() { return () } ``` ## Primitive libraries ### Radix Import the notification publisher from the same package entry as the Toaster mounted in your application layout. ```sh npm install wss3-forge sonner ``` ```tsx import { toast } from 'wss3-forge/sonner' export function notifySaved() { toast.success('Changes saved') } ``` ### React Aria Import the notification publisher from the same package entry as the Toaster mounted in your application layout. ```sh npm install wss3-forge sonner ``` ```tsx import { toast } from 'wss3-forge/sonner' export function notifySaved() { toast.success('Changes saved') } ``` ## Optional primitive contracts - [wss3-forge/sonner · Sonner contract](/ai/skill/primitive-api/Sonner.json)