Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
A simple, unstyled toaster (notification) handler for Nuxt.js that can render any Vue component as a toast.
Nuxt Toaster is a Nuxt.js module for displaying toast notifications; it injects a $nt instance into the app and can render any Vue component, render function, string, or number as toast content.
Nuxt Toaster is an unstyled, TypeScript-based toast notification module built for Nuxt.js. It takes a string or a Vue component as input, renders it inside a configurable container div, and outputs a dismissible toast with role="alert" and keyboard focus support. Published as @cssninja/nuxt-toaster on npm, it is designed to be installed as a dev dependency and registered in the modules array of nuxt.config.js. The module automatically creates a $nt instance on useNuxtApp() that you can call from any component, page, or plugin.
$nt.show() accepts a Vue render function, string, or number; for instance $nt.show(() => h(MyComponent)) renders that component as the toast.duration (default 5000 ms), pauseOnHover (default true), dismissible (default true), maxToasts, transition, and a theme with containerId, containerClass and wrapperClass.theme.containerId maintains its own toast stack, so maxToasts counts only the toasts in that container.$nt.show() calls in app.config.ts under the toaster key to avoid repetition.installPlugin: false and create your own ninjaToaster instance using createNinjaToaster(), then provide your own methods like info or error.useNinjaToasterState() (exposes hover/active state, timer, duration, click, close) and useNinjaToasterProgress() (exposes percent, endAt, closeIn) to build interactive toasts.closeAll(), or close toasts in a specific container via close(containerId) or close(theme).Nuxt Toaster is for Nuxt.js developers who need a lightweight, unstyled toast system that they can fully control. It is particularly useful for teams building custom design systems or using utility-first CSS frameworks like Tailwind.
useNinjaToasterState and useNinjaToasterProgress to implement timers, hover-pause, and progress bars.$nt.show('Hello world') to show a plain string toast that auto-dismisses after the default 5 seconds.() => h(MyToast, { title, type, message }) to display interactive or branded notifications.nt.show() in your own plugin to expose info() and error() methods that each use a different component and styling, as demonstrated with the MyToast component.containerId values to position toasts in separate corners of the screen, each with its own maxToasts limit.After you install and register the module, it automatically creates a $nt instance available on useNuxtApp(). Calling $nt.show() mounts the toast in a container div that the module creates in the DOM, and returns a promise that resolves with the element and a close function when the toast is mounted. The default plugin injects $nt; if you disable it, you build your own instance with createNinjaToaster() and provide it via a custom Nuxt plugin.
Yes, Nuxt Toaster is distributed as a public npm package, which you can install with a package manager and use in as many projects as you like.
Nuxt Toaster does not hard-code a position; you control positioning through CSS. In the minimal theme example, the #nt-container uses flexbox with flex-direction: column-reverse to push toasts to the bottom, and align-items to align left, center, or right. You can also pass custom classes via theme.containerClass.
Yes, because Nuxt Toaster is unstyled, you can pass Tailwind utility classes through containerClass and wrapperClass in the theme option. The documentation shows a custom plugin that applies classes like bg-indigo-600, rounded p-4, and text-rose-500 to a custom toast component.
