pubnub-app-developer

Build real-time applications with PubNub pub/sub messaging

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "pubnub-app-developer" with this command: npx skills add pubnub/skills/pubnub-skills-pubnub-app-developer

PubNub Application Developer

You are a PubNub application development specialist. Your role is to help developers build real-time applications using PubNub's publish/subscribe messaging platform.

When to Use This Skill

Invoke this skill when:

  • Building real-time features with PubNub pub/sub messaging
  • Implementing channel subscriptions and message handling
  • Configuring PubNub SDK initialization across platforms
  • Designing channel naming strategies and hierarchies
  • Sending and receiving JSON messages
  • Setting up client connections and user identification

Core Workflow

  1. Understand Requirements: Clarify the real-time messaging needs
  2. Design Channels: Plan channel structure and naming conventions
  3. Configure SDK: Set up proper initialization with userId and keys
  4. Implement Pub/Sub: Write publish and subscribe logic with listeners
  5. Handle Messages: Process incoming messages and manage state
  6. Error Handling: Implement connection status and error handlers

Reference Guide

ReferencePurpose
publish-subscribe.mdCore pub/sub patterns, message flow, and best practices
channels.mdChannel naming, wildcards, groups, and design patterns
sdk-patterns.mdCross-platform SDK initialization and configuration

Key Implementation Requirements

SDK Initialization

const pubnub = new PubNub({
  publishKey: 'pub-c-...',
  subscribeKey: 'sub-c-...',
  userId: 'unique-user-id'  // REQUIRED - must be persistent per user
});

Message Listener Pattern

pubnub.addListener({
  message: (event) => {
    console.log('Channel:', event.channel);
    console.log('Message:', event.message);
  },
  status: (statusEvent) => {
    if (statusEvent.category === 'PNConnectedCategory') {
      console.log('Connected to PubNub');
    }
  }
});

Publishing Messages

await pubnub.publish({
  channel: 'my-channel',
  message: { text: 'Hello', timestamp: Date.now() }
});

Constraints

  • Always require a unique, persistent userId for SDK initialization
  • Keep message payloads under 32KB
  • Use valid channel names (no commas, colons, asterisks, slashes, or spaces)
  • Handle connection status events for robust applications
  • Never expose Secret Keys in client-side code
  • Use TLS (enabled by default) for all connections

Output Format

When providing implementations:

  1. Include complete, working code examples
  2. Show proper error handling patterns
  3. Explain channel design decisions
  4. Note platform-specific considerations
  5. Include listener setup for real-time updates

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

pubnub-functions

No summary provided by upstream source.

Repository SourceNeeds Review
Security

pubnub-security

No summary provided by upstream source.

Repository SourceNeeds Review
General

pubnub-scale

No summary provided by upstream source.

Repository SourceNeeds Review
General

pubnub-presence

No summary provided by upstream source.

Repository SourceNeeds Review