FluxyChat

Core SDK

User channel

Per-user WebSocket for inbox, notifications, and cross-room events.

Besides room WebSockets, FluxyChat exposes a user channel — one socket per authenticated user for inbox updates, notification fan-out, and account-scoped events.

React hook

import { useUserChannel } from "@fluxy-chat/react";

function NotificationBridge({ client }: { client: FluxyChatClient }) {
  const { connected, lastEvent } = useUserChannel({
    client,
    onEvent: (event) => {
      if (event.type === "inbox_updated") {
        // refresh sidebar
      }
    },
  });

  return <span>{connected ? "Live" : "Offline"}</span>;
}

Vanilla client

After minting a JWT with POST /auth/signin, the response includes user channel paths. Connect with:

const ws = client.connectUser(userId);
ws.onmessage = (ev) => {
  const event = JSON.parse(ev.data);
  console.log(event.type, event);
};

When to use

ChannelScopeUse for
Room WebSocketSingle roomMessages, typing, presence
User channelAccountInbox, push triggers, global notifications

Pair with useInbox (realtime: true) and useNotifications.

HTTP APIs

EndpointPurpose
POST /users/{userId}/eventsPush custom events to user channel
DELETE /users/{userId}/connectionsForce-disconnect all user sockets
GET/POST/DELETE /users/{userId}/watchlistTrack rooms or users for notifications

Caller must be the user or project admin/owner.

See Wire protocol for event types.

On this page