Build

The PubNub Publish/Subscribe JavaScript API Tutorial

2 min read Joe Hanson on Apr 3, 2015
Try PubNub Today

Free up to 1MM monthly messages. No credit card required.

Subscribe to our newsletter

By submitting this form, you are agreeing to our Terms and Conditions and Privacy Policy.

This full tutorial walks you through implementing the PubNub Publish/Subscribe JavaScript API to power real-time bidirectional messaging and data transfer.

pubnub javascript pub/sub api tutorialWe’ve built hundreds of tutorials using our PubNub JavaScript API, from simple chat applications, to data visualizations, to multiplayer games. The API at its core is a powerful way to stream data bidirectionally in real time between any number of connected devices.

Using the publish/subscribe design pattern, devices subscribe to a channel, and can receive data on that channel from a publisher. When it comes to a publish/subscribe JavaScript API, the use cases really are endless!

To get you started, we have a couple quick and dirty tutorials to get you sending and receiving messages via PubNub, but we wanted to do a more in-depth, comprehensive tutorial for those who wanted more. So we had two of our support gurus, Craig and Fred, host the first ever PubNub webinar.

Publish/Subscribe JavaScript Tutorial Overview

In the webinar tutorial, we go step-by-step through getting started with the PubNub JavaScript API, from signing up for a PubNub account all the way to building a simple real-time chat application. Our chat application will also implement the presence API for online user detection, and the history API to store and retrieve old chat messages.

Key topics covered will include:

  • Getting started with PubNub
  • Integrating the latest version of the SDK
  • Accessing the API
  • Initialization/subscribing to data channels
  • Publishing messages and log all sent messages over that channel
  • Presence/State detection (knowing when users enter/leave your app)
  • History (storing real-time data for future retrieval and playback)

Good news is, you didn’t have to be there live, because we recorded the whole thing!

Additional JavaScript API Resources and Tutorials

More from PubNub

Top Trends to Engage Your App Users
InsightsSep 27, 20224 min read

Top Trends to Engage Your App Users

Take a look at the top trends that are the most effective in attracting customers and reducing churn, and how you can incorporate...

PubNub Staff

PubNub Staff

Comparing Game Engines: Unity vs Unreal vs the Rest
Real-Time Gaming BlogSep 21, 20225 min read

Comparing Game Engines: Unity vs Unreal vs the Rest

Comparing the major game engines: Unity vs Unreal Engine vs Corona SDK vs GameMaker Studio, including the benefits and cons of...

PubNub Staff

PubNub Staff

Python Socket Programming: Client, Server and Peer Libraries
BuildSep 21, 20226 min read

Python Socket Programming: Client, Server and Peer Libraries

Sockets (aka socket programming) enable programs to send and receive data, bi-directionally, at any given moment. This tutorial...

PubNub Staff

PubNub Staff