Skip to content

Basic

The smallest complete setup: register the module, mount <NuxtSnackbar /> once, and trigger a toast from a button.

nuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-snackbar'],
})

No options are required — the built-in defaults give you a bottom-anchored toast that auto-dismisses after 4 seconds.

app.vue
<template>
<div>
<NuxtPage />
<NuxtSnackbar />
</div>
</template>
pages/index.vue
<script setup lang="ts">
const snackbar = useSnackbar()
function save() {
snackbar.add({
type: 'success',
text: 'Saved successfully!',
})
}
</script>
<template>
<button @click="save">Save</button>
</template>

Click the button and a green success toast slides in from the bottom, then disappears on its own a few seconds later.

  • Positioning — move toasts to a different corner and tune their duration.
  • Custom Styling — border-style messages, custom colors, and compact toasts.