Watch for Data Changes: $watch

Learn to watch for property changes within AlpineJS components with the $watch magic property.

The $watch magic property

We can use the $watch magic property to watch a property in an AlpineJS component. It accepts two arguments:

  • A property to watch.
  • A second callback argument to call when the property changes.

The example below shows how to use the $watch property:

Get hands-on with 1400+ tech skills courses.