C
CanxJS
v1.6.2
  • Learn
  • Blog
  • Showcase
C
CanxJS

Ultra-fast async MVC backend framework for Bun. Build production-ready APIs with elegance and speed.

Resources

  • Documentation
  • Learn
  • Blog
  • Showcase

Documentation

  • Introduction
  • Installation
  • Core Concepts
  • CLI Commands
  • API Reference

Legal

  • Privacy Policy
  • Terms of Service

© 2026 CanxJS. All rights reserved.

Built with ❤️ for Candra Kirana

Back to Learning Center
Advanced
35 min

WebSocket Integration

Implement WebSocket servers for live updates.

WebSocket Integration

For raw real-time power, CanxJS exposes the underlying WebSocket server (powered by Bun).

Handling Connections

In your src/ws.ts (or similar):

typescript
import { WebSocketServer } from "canxjs";

const wss = new WebSocketServer({
  open(ws) {
    console.log("Client connected");
    ws.subscribe("global");
  },
  message(ws, message) {
    console.log("Received:", message);
    ws.publish("global", `Echo: ${message}`);
  }
});

Integration with HTTP

The WebSocket server shares the same port as your HTTP server, thanks to Bun's single-process model, ensuring zero latency overhead.

Have questions?

Join the discussion on GitHub