Toastflow
Playground
Nuxt

toast vs useToast()

When to use the auto-imported toast object and when useToast is a better fit.

Both are auto-imported by nuxt-toastflow. They point to the same Toastflow runtime.

Use toast

Best for one-off calls in pages, click handlers, composables, and callbacks.

Use useToast()

Best when you want to name the API once and pass it around explicitly.

Side By Side

toast.success({
  title: "Saved",
});

Same Store

const toastApi = useToast();

toastApi.dismissAll();
toast.dismissAll();

Both calls operate on the same queue, timers, subscriptions, and visible toasts.

Common Nuxt Patterns

<script setup lang="ts">
function copyLink() {
  toast.success({ title: "Copied" });
}
</script>

<template>
  <UButton @click="copyLink">Copy link</UButton>
</template>

Client-Side Rule

Do not call toast or useToast() from Nitro routes, server handlers, route middleware that only runs on the server, or SSR-only code. Toasts are UI feedback, so trigger them from client execution.

Quick Decision

Copyright © 2026