Introducing the ๐๐๐๐ท๐๐๐ hook. The same developer experience as useForm, but for plain HTTP requests. Reactive state, error handling, file upload progress, and request cancellation, all without triggering a page visit.
Optimistic updates are now built into Inertia. Chain ๐๐๐๐๐๐๐๐๐๐() before any router visit to apply changes instantly. If the request fails, props revert automatically ๐ซ
The new @๐๐๐๐๐๐๐๐๐/๐๐๐๐ plugin handles page resolution, code splitting, and SSR setup automatically. Your entire entry point can now be a single function call. SSR in development no longer requires a separate Node.js server either. Just run ๐๐๐๐๐๐๐๐ ๐๐๐ โก๏ธ
Lastly, TypeScript users can configure the Flash Data type globally using declaration merging. That way, your page.flash will be fully typed throughout your app ๐
You can also set Flash Data entirely on the client using router.flash(). New values are merged with existing data, and with a callback, you may access or replace the current state โจ
To handle Flash Data globally, listen to the global flash event. This is ideal for toast notifications managed from a single location like your layout component.
Need Flash Data when making requests? Use the onFlash callback. This is great for catching server-generated values like new Model IDs right after form submissions. ๐ฏ
On the frontend, Flash Data is available on the page object. You may access it directly in your components, for example, to show notifications or highlight newly created items. ๐ซ
If you're using this for redirects, you can chain back() onto flash(). You can also use Flash Data for regular page renders, and you may call flash() either before or after returning an Inertia response.
Ready for another new feature? Introducing Flash Data in Inertia! โก๏ธ
With Flash Data, you can send one-time values to your frontend that won't reappear when users navigate through browser history. Perfect for success messages, newly created IDs, or other temporary values.
One last thing: Once you've set up Precognition on useForm(), you may simply call form.submit() without any arguments to submit the form. The method and URL are already known.
Happy validating! โจ
inertiajs.com/docs/v2/the-baโฆ
Previously, when using useForm() with Precognition, you had to install an extra package. As of Inertia 2.3, you can remove it and import useForm() directly from Inertia again.
The API stays the same and we added a new method to enable Precognition, plus support for Wayfinder โต๏ธ
You may also specify which fields to validate, and you can pass success and error listeners. This is great for multistep forms where each step should validate before going to the next one ๐
You may validate fields on events like blur and change, but you can also choose to "touch" fields. Later on, you can simply call validate() to validate all touched fields at once.
In Laravel, the only thing you need is a Form Request and the HandlePrecognitiveRequests middleware on the route. That's it!
When Laravel receives a precognitive request, it runs your middleware and validation exactly like a real submission, but skips executing the controller.
Precognition can be used for various cases, but it's mainly for validating forms as users fill them out before they actually submit the form.
It uses your existing server-side validation rules, so there's nothing to duplicate on the client ๐
Today we're bringing Precognition to Inertia's Form component! ๐ฎ
And not only in the Form component, we're also bringing it to useForm() out of the box. No additional packages needed anymore.