Nuxt · NUXT0040

Keep useFetch lifecycle callbacks replay-safe

Flags mutation toast in useFetch callback in Nuxt project code before it leaks into runtime behavior.
NUXT0040vite-doctor/nuxtfetchingwarnSuggestion

Run this rule

pnpm nuxt doctor --rules nuxt/no-mutation-toast-in-usefetch-callback

Why it matters

Nuxt data fetching relies on stable keys, payload serialization, and request context. Bypassing those contracts can duplicate requests or lose SSR data.

Remove mutation toast in useFetch callback, or move it to the Nuxt runtime/API that owns that behavior.

Example

Move callback effects into actions

Before

await useFetch('/api/orders', {
  method: 'POST',
  onResponse() {
    toast.add({ title: 'Saved' })
  },
})

After

async function saveOrder() {
  await $fetch('/api/orders', { method: 'POST' })
  toast.add({ title: 'Saved' })
}
Copyright © 2026