Node.js Integration

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.

Recommended

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

1

Your backend sends a POST

Call the Notilayer API with a userId, title, and body from your Node.js code.

2

Notilayer delivers via SSE

The notification is pushed to the user's browser in real-time through a persistent SSE connection.

3

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?
Make a POST request to the Notilayer API at https://api.notilayer.com/v1/notify with your API key, a userId, title, and body. You can use native fetch (Node 18+) or axios. The notification is delivered in real-time to the user's browser via SSE.
Can I send notifications to multiple users at once from Node.js?
Yes. The Notilayer batch endpoint at /v1/notify/batch accepts an array of userIds in a single request. This is more efficient than making individual API calls for each user, especially for broadcast-style notifications.
Do I need a WebSocket server to deliver real-time notifications?
No. Notilayer handles real-time delivery via Server-Sent Events (SSE). Your Node.js backend only needs to make REST API calls to trigger notifications. Notilayer manages the persistent connection to each user's browser.
Does Notilayer work with Express, Fastify, and NestJS?
Yes. Since Notilayer uses a standard REST API, it works with any Node.js framework. Whether you use Express, Fastify, NestJS, Hono, or even serverless functions on Vercel or AWS Lambda, you just make an HTTP POST request to trigger a notification.

Send Your First Notification in 5 Minutes

Free API key. No credit card. Working Node.js examples included.