Nuxt · NUXT0040
Keep useFetch lifecycle callbacks replay-safe
Flags mutation toast in useFetch callback in Nuxt project code before it leaks into runtime behavior.
nuxt/no-mutation-toast-in-usefetch-callbacksrc/rule-packs/nuxt/rules/nuxt/no-mutation-toast-in-usefetch-callback.ts Upstream docs 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.
Recommended fix
Remove mutation toast in useFetch callback, or move it to the Nuxt runtime/API that owns that behavior.
Useful links
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' })
}