Send In-App Notifications from Node.js
One API call from your Node.js backend. Real-time delivery to the browser via SSE. No WebSocket server to manage. Working code examples below.
Code Examples
One POST request. That is it.
Use native fetch or axios — both work. No SDK to install unless you want one.
Native fetch (Node 18+)
// Send a notification with native fetch (Node 18+)
const res = await fetch('https://api.notilayer.com/v1/notify', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.NOTILAYER_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
userId: 'user_123',
title: 'New comment on your post',
body: 'Sarah left a comment on "Getting Started".',
}),
});
const data = await res.json();
console.log(data); // { id: "notif_abc", status: "delivered" } With axios
import axios from 'axios';
const notilayer = axios.create({
baseURL: 'https://api.notilayer.com/v1',
headers: {
'Authorization': `Bearer ${process.env.NOTILAYER_API_KEY}`,
},
});
// Send a single notification
await notilayer.post('/notifications', {
userId: 'user_123',
title: 'Invoice paid',
body: 'Payment of $49.00 received.',
}); API Reference
Endpoints you need
Simple REST API. Standard HTTP. Works from any Node.js environment.
| Method | Endpoint | Description |
|---|---|---|
| POST | /v1/notify | Send a notification to one user by ID |
| POST | /v1/notify/batch | Send to a list of users, a segment, or all users |
Batch Sending
Notify multiple users in one request
Broadcast maintenance notices, feature announcements, or team updates to multiple users without looping through individual API calls.
- Send to up to 1,000 users per batch request
- Each notification is delivered in real-time via SSE
- Combine with user segmentation for targeted broadcasts
// Send to multiple users in one request
await fetch('https://api.notilayer.com/v1/notify/batch', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.NOTILAYER_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
userIds: ['user_1', 'user_2', 'user_3'],
title: 'System maintenance',
body: 'Scheduled downtime tonight at 11 PM UTC.',
}),
}); // Express.js route example
app.post('/api/comments', async (req, res) => {
const comment = await db.comments.create(req.body);
// Notify the post author
await fetch('https://api.notilayer.com/v1/notify', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.NOTILAYER_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
userId: comment.postAuthorId,
title: 'New comment',
body: `${req.user.name} commented on your post.`,
}),
});
res.json(comment);
}); Real-World Example
Works with any Node.js framework
Trigger notifications from Express routes, Fastify handlers, NestJS controllers, or serverless functions. It is just an HTTP call.
Express
Fastify
NestJS
Serverless
Architecture
How it works end-to-end
Your backend sends a POST
Call the Notilayer API with a userId, title, and body from your Node.js code.
Notilayer delivers via SSE
The notification is pushed to the user's browser in real-time through a persistent SSE connection.
Bell widget updates instantly
The notification appears in the bell widget. No page refresh. No polling. Instant.
FAQ
Node.js notification questions
How do I send in-app notifications from a Node.js backend?
Can I send notifications to multiple users at once from Node.js?
Do I need a WebSocket server to deliver real-time notifications?
Does Notilayer work with Express, Fastify, and NestJS?
Explore more: Home · API Segmentation · React Notifications Guide
Send Your First Notification in 5 Minutes
Free API key. No credit card. Working Node.js examples included.