max-stan / magento2-mercure
Magento 2 module for real-time publishing via Mercure protocol
Package info
github.com/max-stan/magento2-mercure
Type:magento2-module
pkg:composer/max-stan/magento2-mercure
Requires
- php: >=8.3
- lcobucci/jwt: ^4.0 || ^5.0
- magento/framework: *
- symfony/mercure: ^0.6 || ^1.0
This package is auto-updated.
Last update: 2026-03-08 19:02:33 UTC
README
Magento 2 module that integrates Symfony Mercure to enable real-time, server-sent event (SSE) publishing capabilities for your e-commerce store.
This module provides a Mercure Hub integration layer for Magento 2, enabling real-time server-sent events (SSE) across your storefront and admin panel. It handles JWT-based authentication for both publishing and subscribing, with separate secrets for each operation. Topics are managed through an extensible resolver system that supports both public (guest-accessible) and private (customer-specific) topic authorization.
Warning
This package is currently in alpha (0.1.0-alpha1). The API is unstable and may introduce breaking changes between releases. Do not use in production.
⭐ Features
- SharedWorker SSE — Single connection shared across browser tabs with automatic reconnection
- JWT Authentication — Separate publisher/subscriber token generation with configurable secrets, algorithms (HMAC SHA-256/384/512), and TTL
- Topic-based authorization — Third-party modules have an ability to register their own topics. Public and private topic separation with user-scoped access control
🛠️ Installation
To install Mercure in your Magento 2 project, follow these steps:
# Standard Magento module installation commands composer require max-stan/magento2-mercure:0.1.0-alpha1 bin/magento mod:en MaxStan_Mercure bin/magento setup:upgrade bin/magento setup:di:compile # Sets config values bin/magento config:set mercure/jwt_publisher/jwt_publisher_secret '!ChangeThisMercureHubJWTSecretKey!' bin/magento config:set mercure/jwt_subscriber/jwt_subscriber_secret '!ChangeThisMercureHubJWTSecretKey!' bin/magento config:set mercure/general/enabled 1 bin/magento c:f # Install and configure Mercure Hub in dev mode, available via http://localhost:8080 docker run \ -e SERVER_NAME=':80' \ -e MERCURE_PUBLISHER_JWT_KEY='!ChangeThisMercureHubJWTSecretKey!' \ -e MERCURE_SUBSCRIBER_JWT_KEY='!ChangeThisMercureHubJWTSecretKey!' \ -p 8080:80 \ dunglas/mercure caddy run --config /etc/caddy/dev.Caddyfile
🔁 Magento Compatibility
Can be installed on most 2.x Magento versions
🚀 Contributing
Contributions are welcome! If you find a bug or have a feature request, feel free to open an issue or submit a pull request.