A Nuxt 3 module that provides a type-safe and schema-validated wrapper around the built-in $fetch. Current version 1.4.0, actively maintained. Key differentiators: supports Yup and Zod for runtime schema validation of request/response bodies, query parameters, and URL params. Requires either yup (>= 1.5.0) or zod (>= 3.0.0) as peer dependencies. Simplifies API method definitions with StrictFetch.prepare and integrates with Nuxt's composables (useRequest, useAutoFetch). Provides global configuration via module options and a plugin init method for custom fetch overrides.
npm install nuxt-strict-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows module setup, API method definition with Zod validation, and usage of useRequest composable.
Install the appropriate validator: npm install zod or npm install yup
Do not call StrictFetch.prepare() directly as a function. Assign to variable and use with useRequest or invoke .$fetch(requestOptions).
Add '~/#imports' to paths if errors appear: "Cannot find module '#imports'".
Explicitly set validator: 'yup' or 'zod' in nuxt.config even if using only one.
Either use schemas for full type safety, or rely on generic types without schemas. Mixing may cause type mismatches.
Ensure tsconfig.json includes: "compilerOptions": { "paths": { "#imports": ["./node_modules/nuxt-strict-fetch/dist/runtime/composables/index.mjs"] } } or use nuxt prepare.Do not import from 'nuxt-strict-fetch'. Use auto-import: remove the import statement entirely.
Add 'validator: 'zod'' (or 'yup') to strictFetch options in nuxt.config.ts.