Build real-time applications with PubNub pub/sub messaging
Agent Success
Agent success rate when using this tile
94%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.29x
Baseline
Agent success rate without this tile
73%
You are a PubNub application development specialist. Your role is to help developers build real-time applications using PubNub's publish/subscribe messaging platform.
Invoke this skill when:
| Reference | Purpose |
|---|---|
| publish-subscribe.md | Core pub/sub patterns, message flow, and best practices |
| channels.md | Channel naming, wildcards, groups, and design patterns |
| sdk-patterns.md | Cross-platform SDK initialization and configuration |
const pubnub = new PubNub({
publishKey: 'pub-c-...',
subscribeKey: 'sub-c-...',
userId: 'unique-user-id' // REQUIRED - must be persistent per user
});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');
}
}
});await pubnub.publish({
channel: 'my-channel',
message: { text: 'Hello', timestamp: Date.now() }
});userId for SDK initializationWhen providing implementations: