Pusher Integration for Real-Time Notifications on Website

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1 servicesAll 2065 services
Pusher Integration for Real-Time Notifications on Website
Simple
from 1 business day to 3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Pusher Integration for Real-Time Website Notifications

Pusher is a managed WebSocket service. Client subscribes to channels, server publishes events via HTTP API. No WebSocket infrastructure management — only notification logic.

Installation

npm install pusher        # server library
npm install pusher-js     # client

Server

import Pusher from 'pusher';

const pusher = new Pusher({
  appId: process.env.PUSHER_APP_ID,
  key: process.env.PUSHER_KEY,
  secret: process.env.PUSHER_SECRET,
  cluster: process.env.PUSHER_CLUSTER,
  useTLS: true
});

// Publish event on order status change
async function notifyOrderUpdate(orderId: string, status: string, userId: string) {
  await pusher.trigger(`private-user-${userId}`, 'order-updated', {
    orderId,
    status,
    timestamp: new Date().toISOString()
  });
}

// Authorize private channels
app.post('/pusher/auth', authenticate, (req, res) => {
  const { socket_id, channel_name } = req.body;
  const userId = req.user.id;

  // Check user can subscribe to this channel
  if (channel_name !== `private-user-${userId}`) {
    return res.status(403).json({ error: 'Forbidden' });
  }

  const auth = pusher.authorizeChannel(socket_id, channel_name);
  res.json(auth);
});

Client (React)

import Pusher from 'pusher-js';
import { useEffect, useState } from 'react';

function useOrderNotifications(userId: string) {
  const [notifications, setNotifications] = useState([]);

  useEffect(() => {
    const pusher = new Pusher(process.env.NEXT_PUBLIC_PUSHER_KEY, {
      cluster: process.env.NEXT_PUBLIC_PUSHER_CLUSTER,
      authEndpoint: '/pusher/auth',
      auth: {
        headers: { Authorization: `Bearer ${getToken()}` }
      }
    });

    const channel = pusher.subscribe(`private-user-${userId}`);

    channel.bind('order-updated', (data) => {
      setNotifications(prev => [data, ...prev]);
      showToast(`Order #${data.orderId}: ${data.status}`);
    });

    return () => {
      channel.unbind_all();
      pusher.unsubscribe(`private-user-${userId}`);
      pusher.disconnect();
    };
  }, [userId]);

  return notifications;
}

Presence Channel — Online Statuses

// Who's currently online in room
const channel = pusher.subscribe(`presence-room-${roomId}`, {
  userAuthentication: {
    params: { userId, userName: user.name }
  }
});

channel.bind('pusher:member_added', (member) => {
  console.log(`${member.info.userName} joined`);
});

channel.bind('pusher:member_removed', (member) => {
  console.log(`${member.info.userName} left`);
});

// Current participants
const members = channel.members;

Limitations and Limits

Pusher Channels: free plan 100 concurrent connections, 200k messages/day. Paid plans start from $49/month.

Alternatives for self-hosted: Soketi (open-source Pusher API compatible).

Timeline

Basic notification integration via Pusher: 1–2 days.