Type-safe, real-time WebSocket messaging with authentication, presence, group chat, voice and conference calling, and 12 React hooks — built on Socket.IO.
What's included
Three focused packages. Compose only what you need — from simple one-to-one chat to full group messaging with offline queuing.
Shared SocketEvent enum and EventPayloads interface ensure server and client are always in sync. No more stringly-typed events or mismatched payloads.
Compose only what you need. .useAuth(), .usePresence(), .useMessaging(), .useGroupMessaging() — each plugin is fully independent.
Full group chat: create, join, leave, typing indicators, message history, and queued offline messages delivered automatically on reconnect.
Purpose-built hooks: useSocket, useMessages, useSendMessage, usePresence, useTypingIndicator, useGroup, useGroupMessages, useGroupTyping, useUserGroups, useSocketEvent, useVoiceCall, useConferenceCall.
WebRTC peer-to-peer calls with ICE/STUN/TURN signaling. Sockr handles SDP offer/answer relay and trickle ICE — the useVoiceCall hook manages the full call lifecycle and media streams.
Multi-party group calling via a Selective Forwarding Unit (LiveKit or custom). The server manages room creation and token generation — clients connect directly to the SFU using useConferenceCall.
Users can connect from multiple sockets simultaneously. Offline events broadcast only when the user's last socket disconnects — works seamlessly across tabs and devices.
Bring your own database: MongoDB, PostgreSQL, MySQL, or in-memory. Plus Redis or in-memory queue and cache providers. Implement IMessageStore for any backend.
Architecture
Shared TypeScript types keep server and client in perfect sync — no code generation needed.
Installation
Install from npm. Zero peer dependency conflicts.
npm install sockr-server sockr-client sockr-sharedpnpm add sockr-server sockr-client sockr-sharedyarn add sockr-server sockr-client sockr-sharedQuick Start
A minimal server and React client — ready to run.
import { SocketServer } from 'sockr-server';
const server = new SocketServer({ port: 3000 });
server
.createStandalone()
.useAuth(async (token) => {
const user = await verifyToken(token);
return user ? { userId: user.id } : null;
})
.usePresence()
.useMessaging()
.useGroupMessaging();
await server.listen();
import { SocketProvider } from 'sockr-client/react';
import {
useMessages,
useSendMessage,
usePresence,
} from 'sockr-client/react';
function App() {
return (
<SocketProvider
config={{ url: "http://localhost:3000" }}
token={authToken}
>
<Chat />
</SocketProvider>
);
}
function Chat() {
const { messages } = useMessages();
const { sendMessage } = useSendMessage();
const { isUserOnline } = usePresence();
// ...
}
Packages
Plugin-based WebSocket server. Supports standalone, HTTP attach, and Express modes. Auth, Presence, Messaging, Group, Voice, and Conference plugins with full adapter support.
sockr-client@1.2.0Framework-agnostic SocketClient core plus 12 React hooks including useVoiceCall and useConferenceCall. Works with React, React Native, and plain JavaScript.
Zero-dependency type definitions. The SocketEvent enum, EventPayloads, and all core interfaces — the single source of truth for the protocol.