Full configuration, interactive controls, and API references.
Add the Toaster component once at the root level of your project layout.
// app/layout.tsx (Next.js Root Layout)
import { Toaster } from 'better-toast-react';
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
{children}
<Toaster position="top-center" />
</body>
</html>
);
}Call the toast API anywhere inside your client React components.
import { toast } from 'better-toast-react';
// Simple message
toast('Hello world!');
// Status types
toast.success('Saved successfully!', {
description: 'Your changes are now live.',
});
// Promises
toast.promise(fetchData(), {
loading: 'Loading API...',
success: 'Data loaded!',
error: 'Could not fetch data.',
});