Nuxt Precognition

A validation module for Nuxt that implements the Precognition protocol in a backend-agnostic way.

export default defineNuxtConfig({
  modules: ['nuxt-precognition'],
  precognition: {
    backendValidation: true,
    enableNuxtClientErrorParser: true,
  },
})

intro

Nuxt Precognition

It supports any backend or validation library, and is not tied to Laravel.

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 }
  )
)

Features

  • Laravel compliant
  • Validation library agnostic
  • Client and server side validation
  • TypeScript support
  • Customizable error parsing and status handling