codenyra/precognition-plus
| Install | |
|---|---|
composer require codenyra/precognition-plus |
|
| Latest Version: | v0.2.0 |
| PHP: | ^8.2 |
| Laravel: | 12 · 13 |
| License: | MIT |
| Last Updated: | Nov 20, 2026 |
| Links: | GitHub · Packagist |
Precognition Plus
Precognition Plus checks the simple rules of your FormRequests in the browser, so a Laravel Precognition form only calls the server for the fields that need it. Rules like required, integer, max, regex, alpha_dash and Rule::enum() run in the browser. A field with a rule the browser can't run, such as unique, exists, a closure or a Rule class of your own, still goes to the server, on its own and only after its value changed.
| Composer | codenyra/precognition-plus (namespace CodeNyra\PrecognitionPlus\) |
| npm | precognition-plus |
| Requires | PHP 8.2+, Laravel 12.53+ or 13, laravel-precognition 2.x (Inertia 3's @inertiajs/vue3, react and svelte already include it) |
You need both packages. With only one of them, forms work like plain Precognition.
Setup
composer require codenyra/precognition-plus
npm install precognition-plus
// resources/js/app.ts
import { setupPrecognitionPlus } from 'precognition-plus'
setupPrecognitionPlus()
FormRequests, controllers, components and the HandlePrecognitiveRequests middleware on your routes stay the way the Precognition docs describe them.
How it works, in short
- The first validation of a form goes to the server as usual. Its response also brings back the FormRequest's browser rules, with Laravel's own messages.
- After that, browser rules are checked in the browser. Fields with server rules are sent on their own, and only when their value, or a field their rules name, changed.
- Submitting the form runs full validation on the server, as before.
A form never makes more requests than it would with plain Precognition.
The browser can read the rules
Anyone who passes the FormRequest's authorize() gets its browser rules, parameters included, so in and not_in lists, enum values and regex patterns are public. Rule::in(Coupon::pluck('code')) would show every coupon code to whoever opens the form. Check a list like that with Rule::exists(), a closure or a Rule class of your own instead; those never leave the server.
Documentation
- Installation
- Usage guide
- Rules, every Laravel rule and where it runs
- How it works
- Limitations and troubleshooting
The live demo is a signup form with browser, mixed and server-only fields, and a log of every check. To run it yourself, see demo/.
Development
composer install && composer test # PHP: schema building, precognitive responses
cd js && npm install && npm test # JS: rules, interceptor with stock Inertia Vue/React forms
npm run typecheck && npm run build
| Folder | What |
|---|---|
php/ |
The Composer package (src/, config/) and its tests. composer.json stays at the root, where Packagist reads it. |
js/ |
The npm package, with its own package.json and tests. |
docs/ |
The documentation. |
demo/ |
The demo's files, and setup.sh, which builds a fresh Laravel app with them. |
Related Packages
Define Laravel forms in PHP and render them with Inertia.js in Vue, React, or Sv...
Scaffold Laravel resources for Inertia (Vue/React) or Blade (migration, model, c...
Server-driven admin panels for Laravel + Inertia.js. Define forms, tables, and p...
Multi-authentication scaffolding for Laravel 11, 12, and 13 with support for Bla...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v0.2.0 | ^8.2 | ^12.53| | MIT | |
| v0.1.1 | ^8.2 | ^12.0| | MIT | |
| v0.1.0 | ^8.2 | ^12.0| | MIT |