X Enterprises
Composables

useXToast

Shortcut helpers for firing success, error, warning, and info toast notifications.

useXToast

Thin wrapper around Nuxt UI's useToast that pre-configures icons, colors, and default durations for the four standard notification intents. Eliminates the need to pass repetitive options on every call.

Usage

const { success, error, warning, info } = useXToast()

Returns

KeyTypeDescription
success(message: string, options?: ToastOptions) => voidGreen success toast with a check icon.
error(message: string, options?: ToastOptions) => voidRed error toast with an X icon. Stays visible longer by default.
warning(message: string, options?: ToastOptions) => voidYellow warning toast with an alert icon.
info(message: string, options?: ToastOptions) => voidBlue informational toast with an info icon.

Example

const { success, error, warning } = useXToast()

async function deleteRecord(id: string) {
  try {
    await remove(id)
    success("Record deleted successfully")
  } catch (e) {
    error("Failed to delete record")
  }
}

function notifyDeprecation() {
  warning("This feature will be removed in v2.0")
}

AI Context

composable: useXToast
package: "@xenterprises/nuxt-x-app"
use-when: >
  After any user action that requires feedback — CRUD mutations, form submissions,
  copy-to-clipboard, bulk operations. Always prefer useXToast over calling
  useToast directly to maintain consistent intent styling across the app.
pairs-with: useXCrud, XABulkAction, XACrudModal
Copyright © 2026