Skip to content

Commit 02afe14

Browse files
authored
[12.x] Remove Inertia Precognition integration + Link to Inertia docs (#10946)
* Remove Inertia Precognition integration + Link to Inertia docs * Update precognition.md
1 parent fda374d commit 02afe14

File tree

1 file changed

+3
-71
lines changed

1 file changed

+3
-71
lines changed

precognition.md

Lines changed: 3 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
- [Introduction](#introduction)
44
- [Live Validation](#live-validation)
55
- [Using Vue](#using-vue)
6-
- [Using Vue and Inertia](#using-vue-and-inertia)
76
- [Using React](#using-react)
8-
- [Using React and Inertia](#using-react-and-inertia)
97
- [Using Alpine and Blade](#using-alpine)
108
- [Configuring Axios](#configuring-axios)
119
- [Customizing Validation Rules](#customizing-validation-rules)
@@ -20,6 +18,9 @@ Laravel Precognition allows you to anticipate the outcome of a future HTTP reque
2018

2119
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.
2220

21+
> [!NOTE]
22+
> 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.
23+
2324
<a name="live-validation"></a>
2425
## Live Validation
2526

@@ -187,38 +188,6 @@ You may determine if a form submission request is in-flight by inspecting the fo
187188
</button>
188189
```
189190

190-
<a name="using-vue-and-inertia"></a>
191-
### Using Vue and Inertia
192-
193-
> [!NOTE]
194-
> 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.
195-
196-
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:
197-
198-
```shell
199-
npm install laravel-precognition-vue-inertia
200-
```
201-
202-
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.
203-
204-
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:
205-
206-
```vue
207-
<script setup>
208-
import { useForm } from 'laravel-precognition-vue-inertia';
209-
210-
const form = useForm('post', '/users', {
211-
name: '',
212-
email: '',
213-
});
214-
215-
const submit = () => form.submit({
216-
preserveScroll: true,
217-
onSuccess: () => form.reset(),
218-
});
219-
</script>
220-
```
221-
222191
<a name="using-react"></a>
223192
### Using React
224193

@@ -378,40 +347,6 @@ You may determine if a form submission request is in-flight by inspecting the fo
378347
</button>
379348
```
380349

381-
<a name="using-react-and-inertia"></a>
382-
### Using React and Inertia
383-
384-
> [!NOTE]
385-
> 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.
386-
387-
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:
388-
389-
```shell
390-
npm install laravel-precognition-react-inertia
391-
```
392-
393-
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.
394-
395-
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:
396-
397-
```js
398-
import { useForm } from 'laravel-precognition-react-inertia';
399-
400-
const form = useForm('post', '/users', {
401-
name: '',
402-
email: '',
403-
});
404-
405-
const submit = (e) => {
406-
e.preventDefault();
407-
408-
form.submit({
409-
preserveScroll: true,
410-
onSuccess: () => form.reset(),
411-
});
412-
};
413-
```
414-
415350
<a name="using-alpine"></a>
416351
### Using Alpine and Blade
417352

@@ -616,9 +551,6 @@ window.axios.defaults.headers.common['Authorization'] = authToken;
616551
client.use(window.axios)
617552
```
618553

619-
> [!WARNING]
620-
> The Inertia flavored Precognition libraries will only use the configured Axios instance for validation requests. Form submissions will always be sent by Inertia.
621-
622554
<a name="customizing-validation-rules"></a>
623555
## Customizing Validation Rules
624556

0 commit comments

Comments
 (0)