Nuxt · Data fetching

NUXT0022Export data factories from scanned composable directories

Finds Nuxt fetch code that can be written with a clearer framework-supported pattern.

Why it happens

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

Fix

Use the Nuxt-supported create useFetch must be exported in scanned dir pattern instead.

Example

Use create useFetch must be exported in scanned dir

Before

const useUser = createUseFetch('/api/user')

After

export const useUser = createUseFetch('/api/user')

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm nuxt doctor --rules nuxt/fetch/create-usefetch-must-be-exported-in-scanned-dir
Copyright © 2026