Files
SealShare/.claude/skills/livewire-development/reference/javascript-hooks.md
T
surtic86andClaude Opus 5.5 5679e62c78 Update dependencies
Composer: Laravel 13.43, Octane 2.25, Fortify 1.43 and Pest 5.3.7,
with the packages they bring (70 in all). This fixes the advisories
in Laravel and the Symfony components. npm: Vite 8.3.8 with Rolldown
1.2.19, Playwright 1.65.1 and chokidar 6. The asset build, CI and the
dev container use Node.js 26. The dev image also has git for
Composer. Both audits are clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 06:45:31 +01:00

40 lines
1.1 KiB
Markdown

# Livewire 4 JavaScript integration
## Interceptor system (v4)
### Intercept messages
```js
Livewire.interceptMessage(({ component, message, onFinish, onSuccess, onError }) => {
onFinish(() => { /* After response, before processing */ });
onSuccess(({ payload }) => { /* payload.snapshot, payload.effects */ });
onError(() => { /* Server errors */ });
});
```
### Intercept requests
```js
Livewire.interceptRequest(({ request, onResponse, onSuccess, onError, onFailure }) => {
onResponse(({ response }) => { /* When received */ });
onSuccess(({ response, responseJson }) => { /* Success */ });
onError(({ response, responseBody, preventDefault }) => { /* 4xx/5xx */ });
onFailure(({ error }) => { /* Network failures */ });
});
```
### Component-scoped interceptors
```blade
<script>
this.$intercept('save', ({ component, onSuccess }) => {
onSuccess(() => console.log('Saved!'));
});
</script>
```
## Magic properties
- `$errors` gives JavaScript access to validation errors.
- `$intercept` registers component-scoped interceptors.