Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pusher

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pusher

Node.js client to interact with the Pusher Channels REST API

  • 5.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
498K
increased by37.75%
Maintainers
1
Weekly downloads
 
Created

What is pusher?

The Pusher npm package allows developers to integrate real-time functionality into their applications. It provides features such as real-time messaging, presence channels, and webhooks, making it easier to build interactive and dynamic applications.

What are pusher's main functionalities?

Real-time Messaging

This feature allows you to send real-time messages to clients subscribed to a specific channel. The code sample demonstrates how to initialize the Pusher client and trigger an event on a channel.

const Pusher = require('pusher');

const pusher = new Pusher({
  appId: 'your-app-id',
  key: 'your-key',
  secret: 'your-secret',
  cluster: 'your-cluster',
  useTLS: true
});

pusher.trigger('my-channel', 'my-event', {
  message: 'hello world'
});

Presence Channels

Presence channels build on the functionality of private channels to provide a means of subscribing to the presence of users in a channel. The code sample shows how to trigger an event when a user joins a presence channel.

const Pusher = require('pusher');

const pusher = new Pusher({
  appId: 'your-app-id',
  key: 'your-key',
  secret: 'your-secret',
  cluster: 'your-cluster',
  useTLS: true
});

pusher.trigger('presence-channel', 'user-joined', {
  user_id: 'user123'
});

Webhooks

Webhooks allow you to receive real-time notifications of events happening in your Pusher channels. The code sample demonstrates how to set up a webhook endpoint using Express.js to handle incoming webhook events.

const express = require('express');
const bodyParser = require('body-parser');
const Pusher = require('pusher');

const app = express();
app.use(bodyParser.json());

const pusher = new Pusher({
  appId: 'your-app-id',
  key: 'your-key',
  secret: 'your-secret',
  cluster: 'your-cluster',
  useTLS: true
});

app.post('/pusher/webhook', (req, res) => {
  const webhook = pusher.webhook(req);
  if (webhook.isValid()) {
    console.log(webhook.getEvents());
  }
  res.sendStatus(200);
});

app.listen(3000, () => console.log('Server is running on port 3000'));

Other packages similar to pusher

Keywords

FAQs

Package last updated on 13 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc