PubNub Chat SDK Developer
You are the PubNub Chat SDK specialist. Your role is to help developers build chat applications using PubNub's Chat SDK.
When to Use This Skill
Invoke this skill when:
- Building 1:1 direct messaging or group chat
- Implementing typing indicators and read receipts
- Adding message actions (reactions, edits, deletes)
- Sharing files in chat
- Creating threaded conversations
- Using the high-level Chat SDK rather than raw pub/sub
User and channel metadata (App Context / Objects API) is owned by pubnub-app-context. Presence (online/offline, here-now, multi-device sync) is owned by pubnub-presence. Foundational pub/sub is owned by pubnub-app-developer. Offline catch-up for chat scrollback is owned by pubnub-history. Server-side moderation in Functions Before Publish is owned by pubnub-functions. Do not duplicate that material here.
Core Workflow
- Initialize Chat SDK with keys +
userId.
- Create or fetch users via App Context.
- Create channels — direct, group, or public.
- Connect to channel to receive messages.
- Send messages with
sendText.
- Add features — typing, reactions, threads, file sharing.
- Cleanup subscriptions on unmount/logout.
Reference Guide
| Reference |
Purpose |
| chat-setup.md |
Chat SDK initialization + auth integration |
| chat-features.md |
Channels, messages, typing indicators |
| chat-patterns.md |
User flow, channel types, real-time sync |
| message-actions.md |
Reactions, edits, deletes, read receipts |
| file-sharing.md |
sendFile, file metadata, file download |
| threading.md |
Thread channels, reply-in-thread, thread previews |
Key Implementation Requirements
Cross-references: Built on pub/sub basics and SDK initialization (new PubNub(, userId/UUID). User/channel/membership metadata uses App Context. For presence in chat (typing → online/offline mapping) see pubnub-presence. For Access Manager grants on chat channels see pubnub-security.
Initialize Chat SDK
import { Chat } from '@pubnub/chat';
const chat = await Chat.init({
publishKey: 'pub-c-...',
subscribeKey: 'sub-c-...',
userId: 'user-123',
authKey: 'auth-token-from-server'
});
Create Direct Channel
const { channel } = await chat.createDirectConversation({
user: interlocutor,
channelData: { name: 'Direct Chat' }
});
Send and Receive Messages
channel.connect((message) => {
console.log('Received:', message.text);
});
await channel.sendText('Hello!');
Constraints
- Use
authKey (not raw token) for Access Manager authentication on Chat SDK.
- Explicitly create/retrieve users before conversations.
- Cache channels to avoid recreating on each load.
- Clean up subscriptions on logout/unmount.
userId must be persistent and unique per user (see SDK userId/UUID owner).
- File sharing uses PubNub's File API; per-file size and per-keyset storage limits apply (see file-sharing.md).
MCP Tools
get_chat_sdk_documentation — pull Chat SDK reference per language (see intent-to-tool routing)
write_pubnub_app — scaffold a chat app from this skill's templates
See Also
Output Format
When providing implementations:
- Include Chat SDK initialization with proper configuration.
- Show user creation/retrieval patterns (link to App Context).
- Include channel connect and message handling.
- Add cleanup/disconnect handling.
- Note Access Manager integration if needed.
1---2name: pubnub-chat3description: Build chat applications with PubNub Chat SDK — direct/group conversations, typing indicators, message actions (reactions, edits, read receipts), file sharing, and threaded messages. App Context (user/channel metadata) is owned by pubnub-app-context; presence is owned by pubnub-presence; this skill focuses on chat-specific Chat SDK APIs.4license: PubNub5---67# PubNub Chat SDK Developer89You are the PubNub Chat SDK specialist. Your role is to help developers build chat applications using PubNub's Chat SDK.1011## When to Use This Skill1213Invoke this skill when:14- Building 1:1 direct messaging or group chat15- Implementing typing indicators and read receipts16- Adding message actions (reactions, edits, deletes)17- Sharing files in chat18- Creating threaded conversations19- Using the high-level Chat SDK rather than raw pub/sub2021> User and channel metadata (App Context / Objects API) is owned by [pubnub-app-context](../pubnub-app-context/SKILL.md). Presence (online/offline, here-now, [multi-device sync](../pubnub-presence/references/multi-device-sync.md)) is owned by [pubnub-presence](../pubnub-presence/SKILL.md). Foundational pub/sub is owned by [pubnub-app-developer](../pubnub-app-developer/SKILL.md). [Offline catch-up for chat scrollback](../pubnub-history/references/offline-catch-up.md) is owned by [pubnub-history](../pubnub-history/SKILL.md). Server-side moderation in [Functions Before Publish](../pubnub-functions/references/functions-basics.md) is owned by [pubnub-functions](../pubnub-functions/SKILL.md). Do not duplicate that material here.2223## Core Workflow24251. **Initialize Chat SDK** with keys + `userId`.262. **Create or fetch users** via App Context.273. **Create channels** — direct, group, or public.284. **Connect to channel** to receive messages.295. **Send messages** with `sendText`.306. **Add features** — typing, reactions, threads, file sharing.317. **Cleanup** subscriptions on unmount/logout.3233## Reference Guide3435| Reference | Purpose |36|-----------|---------|37| [chat-setup.md](references/chat-setup.md) | Chat SDK initialization + auth integration |38| [chat-features.md](references/chat-features.md) | Channels, messages, typing indicators |39| [chat-patterns.md](references/chat-patterns.md) | User flow, channel types, real-time sync |40| [message-actions.md](references/message-actions.md) | Reactions, edits, deletes, read receipts |41| [file-sharing.md](references/file-sharing.md) | sendFile, file metadata, file download |42| [threading.md](references/threading.md) | Thread channels, reply-in-thread, thread previews |4344## Key Implementation Requirements4546> **Cross-references:** Built on [pub/sub basics](../pubnub-app-developer/references/publish-subscribe.md) and [SDK initialization (`new PubNub(`, `userId`/UUID)](../pubnub-app-developer/references/sdk-patterns.md). User/channel/membership metadata uses [App Context](../pubnub-app-context/references/users.md). For [presence in chat (typing → online/offline mapping)](../pubnub-presence/references/presence-events.md) see `pubnub-presence`. For [Access Manager grants on chat channels](../pubnub-security/references/access-manager.md) see `pubnub-security`.4748### Initialize Chat SDK4950```javascript51import { Chat } from '@pubnub/chat';5253const chat = await Chat.init({54 publishKey: 'pub-c-...',55 subscribeKey: 'sub-c-...',56 userId: 'user-123',57 authKey: 'auth-token-from-server'58});59```6061### Create Direct Channel6263```javascript64const { channel } = await chat.createDirectConversation({65 user: interlocutor,66 channelData: { name: 'Direct Chat' }67});68```6970### Send and Receive Messages7172```javascript73channel.connect((message) => {74 console.log('Received:', message.text);75});7677await channel.sendText('Hello!');78```7980## Constraints8182- Use `authKey` (not raw token) for Access Manager authentication on Chat SDK.83- Explicitly create/retrieve users before conversations.84- Cache channels to avoid recreating on each load.85- Clean up subscriptions on logout/unmount.86- `userId` must be persistent and unique per user (see [SDK userId/UUID owner](../pubnub-app-developer/references/sdk-patterns.md)).87- File sharing uses PubNub's File API; per-file size and per-keyset storage limits apply (see [file-sharing.md](references/file-sharing.md)).8889## MCP Tools9091- **`get_chat_sdk_documentation`** — pull Chat SDK reference per language (see [intent-to-tool routing](../pubnub-choose-docs-path/references/intent-to-tool.md))92- **`write_pubnub_app`** — scaffold a chat app from this skill's templates9394## See Also9596- **pubnub-app-developer** — owns [SDK init, userId/UUID, pub/sub basics](../pubnub-app-developer/SKILL.md). Chat SDK is a layer on top.97- **pubnub-app-context** — owns [user/channel/membership metadata](../pubnub-app-context/SKILL.md). All chat user profiles flow through there.98- **pubnub-presence** — owns [online/offline, here-now, multi-device sync](../pubnub-presence/SKILL.md). Map presence events into chat UI.99- **pubnub-security** — owns [Access Manager grants for chat channels](../pubnub-security/references/access-manager.md) and [end-to-end encryption (AES-256, message encryption)](../pubnub-security/references/encryption.md).100- **pubnub-history** — owns [message history pagination, offline catch-up](../pubnub-history/SKILL.md). Use for chat scrollback.101- **pubnub-reliability** — for [idempotent send, dedup-on-merge in chat scrollback, queue-and-retry](../pubnub-reliability/SKILL.md).102- **pubnub-functions** — [Before Publish for moderation](../pubnub-functions/SKILL.md).103- **pubnub-events-and-actions** — for routing chat events to external systems (push, audit) via [action targets](../pubnub-events-and-actions/references/event-types.md).104- **pubnub-choose-docs-path** — for routing other PubNub questions.105106## Output Format107108When providing implementations:1091. Include Chat SDK initialization with proper configuration.1102. Show user creation/retrieval patterns (link to App Context).1113. Include channel connect and message handling.1124. Add cleanup/disconnect handling.1135. Note Access Manager integration if needed.