Laravel Precognition Vue Inertia is an official frontend integration package designed to bring "live" validation capabilities to Vue 3 applications that utilize Inertia.js for server-driven UI. It enables developers to anticipate the outcome of future HTTP requests to a Laravel backend, primarily for providing real-time feedback on form inputs without requiring full page reloads. The current stable version of this package is `v2.0.0`, aligning with the core Laravel Precognition library's latest major release. Releases generally follow the development cadence of the broader Laravel ecosystem, with updates often introduced in sync with new Laravel framework versions or significant improvements to the core Precognition package. Its primary differentiator lies in its deep and seamless integration with Laravel's robust validation system and Inertia.js's simplified approach to building single-page applications, offering a highly streamlined developer experience for creating dynamic, interactive forms with instant server-side validation feedback.
npm install laravel-precognition-vue-inertiaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `useForm` to create a basic user creation form with live validation using Laravel Precognition and Vue 3 with Inertia.js.
Migrate any custom request logic to use the `fetch` API or the package's new configuration options. Review the changelog for specific configuration changes regarding XSRF tokens and `Accept` headers.
Confirm `laravel-precognition-vue-inertia` is installed and properly imported. If migrating from older versions of the core `laravel-precognition` that had built-in Inertia support, update your imports to this dedicated package.
Upgrade to `v1.0.1` or newer to ensure correct TypeScript typing for wildcard validation paths. Manual type assertions might be necessary for older versions.
Update `laravel-precognition-vue-inertia` to `v0.5.14` or newer to guarantee compatibility and full support for Inertia 2.0 features.
Ensure `laravel-precognition-vue-inertia` is installed and `useForm` is imported as a named export: `import { useForm } from 'laravel-precognition-vue-inertia';`.Verify your Laravel backend's `Kernel.php` has the `HandlePrecognition` middleware enabled for the web group. Also, ensure the CSRF token is included in your requests (Inertia handles this automatically, but check if custom requests are missing it).
Ensure the generic type passed to `useForm` (`useForm<MyFormType>`) accurately reflects the structure of your form data, including all possible fields and their types.