next-toastv1.0.6
Documentation

Getting started

Add NextToast, mount one renderer, then call toast from a Client Component. React 18 or newer is required.

Installation

Install the package in the app that renders your React interface.

Terminal
pnpm add next-toast
# npm install next-toast
# bun add next-toast

4.9 kB

Minified + gzipped

0

Runtime dependencies

TypeScript

Types included

Mount the renderer

Add one <NextToast /> near the root of your application. Styles are injected automatically.

app/layout.tsx
import { NextToast } from "next-toast";

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>
        {children}
        <NextToast position="top-right" />
      </body>
    </html>
  );
}
Mount only one renderer. Multiple instances can create duplicate stacks.

Trigger a toast

Import toast in a Client Component and call it from an event handler.

save-button.tsx
"use client";

import { toast } from "next-toast";

export function SaveButton() {
  return (
    <button onClick={() => toast.success("Saved")}>
      Save
    </button>
  );
}

Next steps