From b95cdc89710a29b1c22476d0afb44cac4f22b750 Mon Sep 17 00:00:00 2001 From: Pascal Baljet Date: Mon, 8 Dec 2025 21:15:49 +0100 Subject: [PATCH 1/2] Remove Inertia Precognition integration + Link to Inertia docs --- precognition.md | 74 ++----------------------------------------------- 1 file changed, 3 insertions(+), 71 deletions(-) diff --git a/precognition.md b/precognition.md index 3c9608733d..d1fdd8e196 100644 --- a/precognition.md +++ b/precognition.md @@ -3,9 +3,7 @@ - [Introduction](#introduction) - [Live Validation](#live-validation) - [Using Vue](#using-vue) - - [Using Vue and Inertia](#using-vue-and-inertia) - [Using React](#using-react) - - [Using React and Inertia](#using-react-and-inertia) - [Using Alpine and Blade](#using-alpine) - [Configuring Axios](#configuring-axios) - [Customizing Validation Rules](#customizing-validation-rules) @@ -20,6 +18,9 @@ Laravel Precognition allows you to anticipate the outcome of a future HTTP reque When Laravel receives a "precognitive request", it will execute all of the route's middleware and resolve the route's controller dependencies, including validating [form requests](/docs/{{version}}/validation#form-request-validation) - but it will not actually execute the route's controller method. +> [!NOTE] +> As of Inertia 2.3, Precognition support is built-in. Please consult the [Inertia form documentation](https://inertiajs.com/docs/v2/the-basics/forms). Earlier Inertia versions require Precognition 0.x. + ## Live Validation @@ -187,38 +188,6 @@ You may determine if a form submission request is in-flight by inspecting the fo ``` - -### Using Vue and Inertia - -> [!NOTE] -> If you would like a head start when developing your Laravel application with Vue and Inertia, consider using one of our [starter kits](/docs/{{version}}/starter-kits). Laravel's starter kits provide backend and frontend authentication scaffolding for your new Laravel application. - -Before using Precognition with Vue and Inertia, be sure to review our general documentation on [using Precognition with Vue](#using-vue). When using Vue with Inertia, you will need to install the Inertia compatible Precognition library via NPM: - -```shell -npm install laravel-precognition-vue-inertia -``` - -Once installed, Precognition's `useForm` function will return an Inertia [form helper](https://inertiajs.com/forms#form-helper) augmented with the validation features discussed above. - -The form helper's `submit` method has been streamlined, removing the need to specify the HTTP method or URL. Instead, you may pass Inertia's [visit options](https://inertiajs.com/manual-visits) as the first and only argument. In addition, the `submit` method does not return a Promise as seen in the Vue example above. Instead, you may provide any of Inertia's supported [event callbacks](https://inertiajs.com/manual-visits#event-callbacks) in the visit options given to the `submit` method: - -```vue - -``` - ### Using React @@ -378,40 +347,6 @@ You may determine if a form submission request is in-flight by inspecting the fo ``` - -### Using React and Inertia - -> [!NOTE] -> If you would like a head start when developing your Laravel application with React and Inertia, consider using one of our [starter kits](/docs/{{version}}/starter-kits). Laravel's starter kits provide backend and frontend authentication scaffolding for your new Laravel application. - -Before using Precognition with React and Inertia, be sure to review our general documentation on [using Precognition with React](#using-react). When using React with Inertia, you will need to install the Inertia compatible Precognition library via NPM: - -```shell -npm install laravel-precognition-react-inertia -``` - -Once installed, Precognition's `useForm` function will return an Inertia [form helper](https://inertiajs.com/forms#form-helper) augmented with the validation features discussed above. - -The form helper's `submit` method has been streamlined, removing the need to specify the HTTP method or URL. Instead, you may pass Inertia's [visit options](https://inertiajs.com/manual-visits) as the first and only argument. In addition, the `submit` method does not return a Promise as seen in the React example above. Instead, you may provide any of Inertia's supported [event callbacks](https://inertiajs.com/manual-visits#event-callbacks) in the visit options given to the `submit` method: - -```js -import { useForm } from 'laravel-precognition-react-inertia'; - -const form = useForm('post', '/users', { - name: '', - email: '', -}); - -const submit = (e) => { - e.preventDefault(); - - form.submit({ - preserveScroll: true, - onSuccess: () => form.reset(), - }); -}; -``` - ### Using Alpine and Blade @@ -616,9 +551,6 @@ window.axios.defaults.headers.common['Authorization'] = authToken; client.use(window.axios) ``` -> [!WARNING] -> The Inertia flavored Precognition libraries will only use the configured Axios instance for validation requests. Form submissions will always be sent by Inertia. - ## Customizing Validation Rules From c2e3cf2bacb3ecb03d24f33cbf3d725a40b13db0 Mon Sep 17 00:00:00 2001 From: Pascal Baljet Date: Mon, 8 Dec 2025 21:21:37 +0100 Subject: [PATCH 2/2] Update precognition.md --- precognition.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/precognition.md b/precognition.md index d1fdd8e196..f8a181e84d 100644 --- a/precognition.md +++ b/precognition.md @@ -19,7 +19,7 @@ Laravel Precognition allows you to anticipate the outcome of a future HTTP reque When Laravel receives a "precognitive request", it will execute all of the route's middleware and resolve the route's controller dependencies, including validating [form requests](/docs/{{version}}/validation#form-request-validation) - but it will not actually execute the route's controller method. > [!NOTE] -> As of Inertia 2.3, Precognition support is built-in. Please consult the [Inertia form documentation](https://inertiajs.com/docs/v2/the-basics/forms). Earlier Inertia versions require Precognition 0.x. +> As of Inertia 2.3, Precognition support is built-in. Please consult the [Inertia Forms documentation](https://inertiajs.com/docs/v2/the-basics/forms) for more information. Earlier Inertia versions require Precognition 0.x. ## Live Validation