azure-web-pubsub-ts
Build Real-Time Apps with Azure Web PubSub
Implement WebSocket-based real-time messaging in your applications using Azure Web PubSub SDKs. This skill provides production-ready patterns for pub/sub messaging, group management, and connection handling with TypeScript.
Download the skill ZIP
Upload in Claude
Go to Settings → Capabilities → Skills → Upload skill
Toggle on and start using
Test it
Using "azure-web-pubsub-ts". Generate client token with user ID and group membership
Expected outcome:
Token generated with URL wss://resource.webpubsub.azure.com/client/access/hubs/chat?access_token=xxx, userId=user123, groups=[chat-room], roles=[webpubsub.joinLeaveGroup, webpubsub.sendToGroup]
Using "azure-web-pubsub-ts". Send message to all users in chat-room group
Expected outcome:
Message broadcast successfully to 12 connections in group chat-room. Message content: {type: 'message', data: 'Hello everyone!'}
Security Audit
SafeThis skill contains legitimate Azure Web PubSub SDK documentation. Static analyzer produced 35 false positive external_commands findings by misinterpreting markdown code block backticks as shell execution. Network and environment variable patterns are standard Azure SDK usage. No malicious intent detected.
Medium Risk Issues (1)
Low Risk Issues (2)
Risk Factors
🌐 Network access (2)
🔑 Env variables (3)
Quality Score
What You Can Build
Real-Time Chat Application
Build a multi-room chat system with user authentication, group messaging, and presence indicators using Azure Web PubSub groups and user-targeted messaging.
Live Dashboard Updates
Push real-time data updates to connected dashboards using broadcast messaging. Ideal for monitoring systems, analytics displays, or live metrics visualization.
Multiplayer Game Lobby
Create game rooms with player matchmaking, in-game messaging, and session management using groups and connection management APIs.
Try These Prompts
Set up Azure Web PubSub server-side client using the connection string from environment variables. Create a hub named 'chat' and generate a basic client access token.
Generate a client access token for user 'user123' with roles for joining groups, sending to groups, and auto-join the 'chat-room' group. Set expiration to 60 minutes.
Create a WebPubSubClient that connects via a negotiate endpoint. Register handlers for connected, group-message, and disconnected events. Join the 'chat-room' group after connection.
Implement an Express middleware handler for the 'chat' hub with handleConnect validation, handleUserEvent processing, and onConnected logging. Include a negotiate endpoint that generates tokens for authenticated users.
Best Practices
- Use DefaultAzureCredential for production instead of access keys for better security
- Register all event handlers before calling client.start() to avoid missing initial events
- Validate authentication in handleConnect to reject unauthorized connections early in the handshake
Avoid
- Hardcoding connection strings or access keys directly in source code instead of using environment variables
- Accessing process.env variables without TypeScript non-null assertion or fallback values
- Sending messages before verifying client connection state is 'connected'
Frequently Asked Questions
What is the difference between @azure/web-pubsub and @azure/web-pubsub-client?
How do I authenticate users with Azure Web PubSub?
What happens when a client disconnects unexpectedly?
Can I send messages to specific users versus all users?
How do groups work in Azure Web PubSub?
What is the negotiate endpoint pattern?
Developer Details
Author
sickn33License
MIT
Repository
https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-web-pubsub-tsRef
main
File structure
📄 SKILL.md