livewire

Livewire

Specific best practices and architectural patterns when working with Livewire.

Details

Language / Topic
phpPHP
Category
framework

Rules

balanced

Livewire

- Keep component state minimal — only store what the template needs. Use `wire:model` for two-way binding and `wire:click` for actions. Use computed properties (`#[Computed]`) for derived data that shouldn't be stored in state.

Livewire

- Keep component state minimal — only store what the template needs. Use `wire:model` for two-way binding and `wire:click` for actions. Use computed properties (`#[Computed]`) for derived data that shouldn't be stored in state.
- Use `wire:model.live` for real-time binding, `wire:model.blur` for on-blur updates. Use `$this->dispatch('event-name')` for cross-component communication. Implement form objects with `#[Validate]` attributes for clean validation. Use `wire:loading` for loading states during server roundtrips. Use `wire:navigate` for SPA-like page transitions.