
Bun Websocket Server
A solid reference for Bun's native WebSocket implementation that covers the essentials without the usual Node.js ceremony. You get the upgrade pattern with Bun.serve, built-in pub/sub with topics for broadcasting, and typed data attachment per connection. The examples are practical, covering chat rooms, authentication gates, and server-side publishing outside request handlers. Honestly, the pub/sub being native is the real win here. You don't need a separate library for room-based messaging. Good for real-time features where you want fewer dependencies and tighter integration with Bun's HTTP layer.
- skills.sh installs
- 326
- GitHub stars
- 248
- last updated
- Aug 21, 2026
Install
$ npx -y skills add secondsky/claude-skills --skill bun-websocket-server --agent claude-codeInstalls into .claude/skills of the current project.
Files
Bun WebSocket Server
Bun has built-in WebSocket support integrated with Bun.serve().
Quick Start
const server = Bun.serve({
fetch(req, server) {
// Upgrade to WebSocket
if (server.upgrade(req)) {
return; // Upgraded successfully
}
return new Response("Not a WebSocket request", { status: 400 });
},
websocket: {
open(ws) {
console.log("Client connected");
},
message(ws, message) {
console.log("Received:", message);
ws.send(`Echo: ${message}`);
},
close(ws) {
console.log("Client disconnected");
},
},
});
console.log(`WebSocket server running on ws://localhost:${server.port}`);
WebSocket Handlers
Bun.serve({
fetch(req, server) {
server.upgrade(req);
},
websocket: {
// Client connected
open(ws) {
console.log("New connection");
},
// Message received
message(ws, message) {
// message is string | Buffer
if (typeof message === "string") {
console.log("Text:", message);
} else {
console.log("Binary:", message);
}
},
Sponsors
Promote your product hereReach 125k+ visitors monthlyPromote your product hereReach 125k+ visitors monthly
Agent CaffeineSponsoredClose your lid, come back to finished work
SnugSponsoredThe clipboard manager for the AI eraPromote your product hereReach 125k+ visitors monthly
WaxSponsoredBlock anything with supervision, without erasing your iPhonePromote your product hereReach 125k+ visitors monthly
knobsSponsoredSee your site on any phone, any day, in any language
Details
- Repository
- github.com/secondsky/claude-skills
- Category
- Backend & APIs
- First seen
- Jun 3, 2026
More from secondsky/claude-skills
All 146- Cloudflare Workers Runtime Apis326
- Swift Best Practices326
- Bun Nuxt323
- Bun Macros322
- Cloudflare Workers Frameworks321
- Supabase Postgres Best Practices319
- Cloudflare Workers Ci Cd318
- Cloudflare Workers Dev Experience317
- Cloudflare Workers Observability315
- Cloudflare Workers Migration310
- Cloudflare Workers Multi Lang310
- Verification Before Completion310
- Nuxt Studio308
- Neon Vercel Postgres294
- Chrome Devtools288
- Database Sharding277
- Sveltia Cms277
- Google Gemini File Search272
- Tailwind V4 Shadcn8.2K
- Aceternity Ui1.6K
- Vitest Testing1.3K
- Motion1.1K
- Playwright1.1K
- Api Testing910
Recommended
More Backend & APIs1
Add Admin API EndpointTryGhost/GhostAdd a new endpoint or endpoints to Ghost's Admin API at `ghost/api/admin/**`.0skills.sh installs
2
spring-boot-rest-api-standardsgiuseppe-trisciuoglio/developer-kitProvides REST API design standards and best practices for Spring Boot projects. Use when creating or reviewing REST endpoints, DTOs, error handling, pagination,4.3Kskills.sh installs
3
unit-test-wiremock-rest-apigiuseppe-trisciuoglio/developer-kitProvides patterns for unit testing external REST APIs using WireMock. Stubs API responses, verifies request details, simulates failures (timeouts, 4xx/5xx error3.9Kskills.sh installs
4
rest-api-designaj-geddes/useful-ai-promptsDesign RESTful APIs following best practices for resource modeling, HTTP methods, status codes, versioning, and documentation. Use when creating new APIs, desig2.1Kskills.sh installs
5
postgresql-database-engineeringmanutej/luxor-claude-marketplaceComprehensive PostgreSQL database engineering skill covering indexing strategies, query optimization, performance tuning, partitioning, replication, backup and 1.8Kskills.sh installs
6
agent-dev-backend-apiruvnet/rufloAgent skill for dev-backend-api - invoke with $agent-dev-backend-api1.1Kskills.sh installs