Recipes
Recipes
Task-focused guides for the things you actually reach for — on-demand sends, queueing end-to-end, writing your own channel, and wiring up Telescope.
Short, copy-pasteable guides for common jobs. Each one stands on its own — pick the task you have.
- On-demand notifications — send to a raw email or Slack URL with no user entity. Perfect for ops alerts.
- Queued notifications — move delivery off the request,
end to end: registry,
resolveNotifiable, and a dispatcher. - Real-time & in-app — the whole live notification loop: persist with the database channel, push with SSE or WebSocket, consume in React — and how to pick SSE vs WebSocket.
- In-app notifications — render a feed from persisted notifications: list, unread count, mark read, and a one-call REST controller.
- Channel preferences — let users mute channels; muted channels are auto-skipped, with per-tenant scoping.
- Injecting services — pull a provider into a notification with
NestJS's own
@Inject, so it staysnew-able with data and still uses DI. - Writing a custom channel — implement a
ChannelDriver(an SMS channel) and have it discovered automatically. - Telescope integration — record every send in the nestjs-telescope dashboard with one watcher.
Redis
A dedicated notification worker without BullMQ. The dispatcher pushes serialized jobs onto a Redis list; a long-running worker drains it with a blocking BRPOP loop and isolates per-job failures.
On-demand notifications
Send to a raw address — an email, a Slack webhook, a phone number — without a Notifiable entity. Use notifications.route(channel, value).notify(notification) for one-off and ops alerts.