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

  • Citadel (Admin)
  • Dominion (RBAC)
  • Blocks (Modules)
  • Echo (Realtime)
  • Telescope (Debug)
  • Payment (Midtrans)
Official Package

Echo

@canxjs/echo is a client-side library for subscribing to channels and listening to events broadcast by your CanxJS server.

Installation

terminal
1npm install @canxjs/echo socket.io-client

Setup

Initialize Echo in your client-side application (e.g., React, Vue, or vanilla JS).

echo.js
1import Echo from "@canxjs/echo";
2import io from "socket.io-client";
3
4const echo = new Echo({
5 broadcaster: "socket.io",
6 host: "http://localhost:3000",
7 client: io
8});

Listening for Events

app.js
1// Listen to a public channel
2echo.channel("orders")
3 .listen("OrderShipped", (e) => {
4 console.log(e.order.name);
5 });

Private Channels

For private channels, authentication is handled automatically.

app.js
1// Private channels (auth handled automatically)
2echo.private("user.1")
3 .listen("NotificationReceived", (e) => {
4 // ...
5 });

Leaving a Channel

app.js
1echo.leave("orders");

Next Steps

Explore more real-time and enterprise features.