Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Livewire

$wire.$js Syntax Changes in Livewire v4

New cleaner syntax for defining JavaScript actions.

1 February 20261 min readLivewireاقرأ بالعربية

On this page

  1. Before (v3 - Deprecated)
  2. After (v4)
  3. Benefits

Livewire v4 introduces a cleaner syntax for $wire.$js.

Before (v3 - Deprecated)

javascript
$wire.$js('bookmark', () => {
    // Toggle bookmark...
});

// Or
$js('bookmark', () => {
    // Toggle bookmark...
});

After (v4)

javascript
$wire.$js.bookmark = () => {
    // Toggle bookmark...
};

// Or in component
this.$js.bookmark = () => {
    // Toggle bookmark...
};

Benefits

- Cleaner object-style syntax
- More intuitive naming
- Better IDE support
All articles

Keep reading

  • Authorization in Livewire v4 Components1 February 20261 min read
  • Blaze Pre-Compiler: Massive Performance Gains in Livewire v41 February 20261 min read
  • Building a Bookmark Feature with Livewire v41 February 20261 min read