nuxt-precognition
Nuxt Precognition
Nuxt Precognition is a validation module for Nuxt that implements the Precognition protocol in a backend-agnostic way. It supports any backend or validation library, and is not tied to Laravel.
Requirements
- Nuxt >= 3.x
- Node.js >= 18
Why Nuxt Precognition?
- Backend agnostic: Works with any backend that supports the Precognition protocol.
- Validation library agnostic: Use Zod, Yup, or any other validation library.
- Client & server side validation: Seamless validation on both ends.
- Optimal TypeScript support: Typesafe forms and error handling.
- Highly customizable: Plug in your own error parsers and status handlers.
Quick Example
interface User {
email: string
password: string
}
const form = useForm(
(): User => ({ email: '', password: '' }),
(body, headers) => $fetch('/api/login', { method: 'POST', headers, body })
)
Installation
Install the module in your Nuxt app:
npx nuxi module add nuxt-precognition
Contributing
# Install dependencies
npm install
# Generate type stubs
npm run dev:prepare
# Develop with the playground
npm run dev
# Build the playground
npm run dev:build
# Run ESLint
npm run lint
# Run Vitest
npm run test
npm run test:watch
# Release new version
npm run release
License
MIT © [sot1986]
Related Packages
@sidebase/nuxt-parse
Parse, validate and transform data with confidence in nuxt using `zod`
12,669
54
Version History
| Version | Released | Vue | License |
|---|---|---|---|
| 0.3.1 | ^3.0 | MIT | |
| 0.3.0 | ^3.0 | MIT | |
| 0.2.0 | ^3.0 | MIT | |
| 0.1.7 | ^3.0 | MIT | |
| 0.1.6 | ^3.0 | MIT | |
| 0.1.4 | ^3.0 | MIT | |
| 0.1.3 | ^3.0 | MIT | |
| 0.1.2 | ^3.0 | MIT | |
| 0.1.1 | ^3.0 | MIT | |
| 0.0.9 | ^3.0 | MIT | |
| 0.0.8 | ^3.0 | MIT | |
| 0.0.7 | ^3.0 | MIT | |
| 0.0.6 | ^3.0 | MIT | |
| 0.0.5 | ^3.0 | MIT | |
| 0.0.4 | ^3.0 | MIT | |
| 0.0.3 | ^3.0 | MIT | |
| 0.0.2 | ^3.0 | MIT |