/symfony-ux-skills:ux-notifyfrom symfony-ux-skills
Sends desktop notifications to users via Symfony Notifier and Mercure. Renders a listener with stream_notifications() and sends messages with ChatMessage and MercureOptions.
Ships in symfony-ux-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Send a message from PHP with Symfony Notifier, and every browser listening on its Mercure topic shows a native system notification (the Notifications API). stream_notifications() renders the listener.
composer require symfony/ux-notify
Requires StimulusBundle and a running Mercure hub. The package pulls in symfony/mercure-bundle and symfony/mercure-notifier. With Webpack Encore or Reprise, run npm install --force and rebuild.
# config/packages/notifier.yaml
framework:
notifier:
chatter_transports:
mercure: '%env(MERCURE_DSN)%'
# .env
MERCURE_DSN=mercure://default # hub "default", default topic https://symfony.com/notifier
{{ stream_notifications() }} Listen on https://symfony.com/notifier
{{ stream_notifications('/sales') }} One topic
{{ stream_notifications(['/sales', '/news']) }} Several topics
new ChatMessage($title, new MercureOptions(...)) Send from PHP
use Symfony\Component\Notifier\Bridge\Mercure\MercureOptions;
use Symfony\Component\Notifier\ChatterInterface;
use Symfony\Component\Notifier\Message\ChatMessage;
final readonly class FlashSaleAnnouncer
{
public function __construct(private ChatterInterface $chatter) {}
public function announce(): void
{
$message = new ChatMessage(
'Flash sale started!', // notification title
new MercureOptions(
topics: ['/sales'],
content: ['body' => '-30% on everything until midnight', 'icon' => '/images/sale.png'],
),
);
$this->chatter->send($message->transport('mercure'));
}
}
content becomes the notification options: body, icon, tag, badge, requireInteraction... Every message needs a subject: it becomes the notification title.
{# templates/base.html.twig, in <body> #}
{{ stream_notifications('/sales') }}
It renders an empty <div> with the @symfony/ux-notify/notify controller. The controller opens one EventSource per topic and closes them on disconnect. With no argument, it listens on https://symfony.com/notifier, the default topic of the Mercure transport: messages sent without MercureOptions arrive there.
On the first message, the controller asks for permission while the user has yet to grant or deny it. Browsers increasingly ignore permission requests made without a user gesture, so ask from a click:
// assets/controllers/notification_permission_controller.js
import { Controller } from '@hotwired/stimulus';
export default class extends Controller {
request() {
Notification.requestPermission();
}
}
<button data-controller="notification-permission" data-action="notification-permission#request">
Enable notifications
</button>
The Notifications API only runs in a secure context: HTTPS, or localhost in development.
Pass your own Stimulus controller through options; it receives the event sources on notify:connect:
{{ stream_notifications('/sales', {'data-controller': 'sales-notify'}) }}
// assets/controllers/sales_notify_controller.js
import { Controller } from '@hotwired/stimulus';
export default class extends Controller {
initialize() {
this.onConnect = this.onConnect.bind(this);
}
connect() {
this.element.addEventListener('notify:connect', this.onConnect);
}
disconnect() {
this.element.removeEventListener('notify:connect', this.onConnect);
}
onConnect(event) {
event.detail.eventSources.forEach((source) => {
source.addEventListener('message', (message) => {
const { summary, content } = JSON.parse(message.data);
// e.g. also show an in-page toast
});
});
}
}
Of options, only data-controller is read: put other attributes on a wrapper element.
# config/packages/notify.yaml
notify:
mercure_hub: mercure.hub.default # Mercure hub service ID
Since Symfony UX 3.6+, Notify follows the hub's protocol_version (MercureBundle 0.6 defaults to 1.0) and subscribes with match or topic accordingly.
private: false, the default): the EventSource connects without credentials, so it receives public updates only.type option of MercureOptions empty: the controller listens to the default message event only.symfony/ux-notify on Packagist.notify:connectWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
symfony-ux, desktop-notifications, mercure, notifications-api
20 skills in this plugin
/live-componentSymfony UX LiveComponent: live search, live filters, dependent selects and form validation as users type. Use for reactive PHP and Twig components, #[AsLiveComponent], LiveProp, LiveAction, data-model, loading states, emit/listen, lazy rendering and LiveResponse downloads./stimulusSymfony UX Stimulus: JavaScript behavior for dropdowns, tabs, modals, clipboard buttons and third-party widgets. Use for StimulusBundle, data-controller, data-action, targets, values, outlets, lazy controllers and Twig stimulus_* helpers./symfony-uxSymfony UX: choose and combine packages for a Symfony frontend. Use when deciding between Stimulus, Turbo, TwigComponent and LiveComponent, or fitting several Symfony UX packages into the same feature. Prefer the dedicated skill for a task that fits one package.npx claudepluginhub smnandre/symfony-ux-skills --plugin symfony-ux-skillsOther plugins' skills for the same job