Loading...
Loading...
Build chat applications with PubNub Chat SDK
npx skill4agent add pubnub/skills pubnub-chat| Reference | Purpose |
|---|---|
| chat-setup.md | Chat SDK initialization and configuration |
| chat-features.md | Channels, messages, reactions, typing indicators |
| chat-patterns.md | User management, channel types, real-time sync |
import { Chat } from '@pubnub/chat';
const chat = await Chat.init({
publishKey: 'pub-c-...',
subscribeKey: 'sub-c-...',
userId: 'user-123',
// For Access Manager: use authKey (not token)
authKey: 'auth-token-from-server'
});const { channel } = await chat.createDirectConversation({
user: interlocutor, // The other user
channelData: { name: 'Direct Chat' }
});// Connect to receive messages
channel.connect((message) => {
console.log('Received:', message.text);
});
// Send message
await channel.sendText('Hello!');authKeytoken