Quick Start

Get started with Nuxt Notify in just a few minutes!


Basic Configuration

Add basic configuration to your nuxt.config.ts:

nuxt.config.ts
export default defineNuxtConfig({
  modules: ["nuxt-notify"],

  notify: {
    position: "top-right",
    duration: 5000,
    maxToasts: 5,
    theme: "dark",
    showIcon: true,
  },
});

Your First Toast

Use the useToast() composable in any component:

pages/index.vue
<script setup>
const toast = useToast();

function showToast() {
  toast.success("Success!", "Your first toast notification");
}
</script>

<template>
  <div>
    <button @click="showToast">Show Toast</button>
  </div>
</template>

Toast Types

Nuxt Notify provides 4 built-in toast types.


Success Toast

success
<script setup>
const toast = useToast();

toast.success("Saved", "Your changes were saved successfully");
</script>

Error Toast

error
<script setup>
const toast = useToast();

toast.error("Error", "Something went wrong");
</script>

Info Toast

info
<script setup>
const toast = useToast();

toast.info("Heads up", "New version is available");
</script>

Warning Toast

warning
<script setup>
const toast = useToast();

toast.warning("Careful", "This action cannot be undone");
</script>

Custom Toast

For more control, use the add() method:

custom
<script setup>
const toast = useToast();

toast.add({
  type: "success",
  title: "Welcome!",
  description: "Thanks for trying Nuxt Notify",
  duration: 3000,
});
</script>

Configuration Options

Here are the main configuration options:

OptionTypeDefaultDescription
positionstring'top-right'Toast position on screen
durationnumber5000How long toast stays visible (ms)
maxToastsnumber5Maximum toasts on screen
themestring'light'Theme: 'light', 'dark', or 'system'
showIconbooleantrueShow/hide icons