Socket
Socket
Sign inDemoInstall

pubnub

Package Overview
Dependencies
10
Maintainers
7
Versions
214
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pubnub

Publish & Subscribe Real-time Messaging with PubNub


Version published
Weekly downloads
164K
decreased by-3.22%
Maintainers
7
Created
Weekly downloads
 

Changelog

Source

v8.0.1

April 23 2024

Modified
  • Provider configuration option to set service worker from the URL (because of browser restrictions for worker files to be registered from the same domain).

Readme

Source

PubNub JavaScript SDK (V4)

Build Status Codacy Badge npm Bower Known Vulnerabilities

This is the official PubNub JavaScript SDK repository.

PubNub takes care of the infrastructure and APIs needed for the realtime communication layer of your application. Work on your app's logic and let PubNub handle sending and receiving data across the world in less than 100ms.

Get keys

You will need the publish and subscribe keys to authenticate your app. Get your keys from the Admin Portal.

Tutorial Video

Getting Started with PubNub JS SDK

Watch Getting Started with PubNub JS SDK on Dashcam

Configure PubNub

  1. Integrate the JavaScript SDK into your project:

    • use npm:
      npm install pubnub
      
    • or download one of our builds from our CDN:
  2. Configure your keys:

pubnub = new PubNub({
  publishKey : "myPublishKey",
  subscribeKey : "mySubscribeKey",
  uuid: "myUniqueUUID"
})

Add event listeners

pubnub.addListener({
  message: function (m) {
    // handle messages
  },
  presence: function (p) {
    // handle presence  
  },
  signal: function (s) {
    // handle signals
  },
  objects: (objectEvent) => {
    // handle objects
  },
  messageAction: function (ma) {
    // handle message actions
  },
  file: function (event) {
    // handle files  
  },
  status: function (s) {
  // handle status  
  },
});

Publish/subscribe

var publishPayload = {
    channel : "hello_world",
    message: {
        title: "greeting",
        description: "This is my first message!"
    }
}

pubnub.publish(publishPayload, function(status, response) {
    console.log(status, response);
})

pubnub.subscribe({
    channels: ["hello_world"]
});

Documentation

Support

If you need help or have a general question, contact support@pubnub.com.

Keywords

FAQs

Last updated on 23 Apr 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc