Recipe: Mercure Live Updates

What / When

Enable Mercure when another process (or another tab) can change the underlying data and the table should refresh without a full page reload.

Minimal Example

use App\Entity\Book;
use Pentiminax\UX\DataTables\Attribute\AsDataTable;
use Pentiminax\UX\DataTables\Model\AbstractDataTable;

#[AsDataTable(Book::class, mercure: true)]
final class BookDataTable extends AbstractDataTable
{
}

Requires symfony/mercure-bundle and a configured hub. On each Mercure message the Stimulus controller calls table.ajax.reload(null, false).

Pitfalls