New watch() function in WordPress 7.0
WordPress 7.0 adds a watch() function to the @wordpress/interactivity package. This brand-new function subscribes to changes in any reactive value accessed inside a callbackโand reruns it anytime those values change.
Now, you can tie the Interactivity APIโs data-wp-watch to a DOM elementโs lifecycle and use that for reacting to state changes. But how would a process observe those changes programmatically, independently of the DOM? How could you set something up to run side effects at the store level, set up logging, or synchronize state between stores? The watch() function fills this gap.
Check it out: https://make.wordpress.org/core/2026/02/23/changes-to-the-interactivity-api-in-wordpress-7-0/