@ibnlanre/socket
Stay
connected.
Live data has a life of its own.
Give it a place in your React app.
A type-safe WebSocket and Server-Sent Events client with shared connections, cached state, and a way back when the network drops.
Start building Meet SocketMany places to belong.S
↳
pnpm add @ibnlanre/socket01 / The essentials
Less plumbing.
More possibility.
The connection is only the beginning.
Socket takes care of what comes after.
A shared connection.
Identical parameters reuse the same socket. Every component gets its own view of the same stream.
Socket pooling ↗02Something to return to.
Read previously received data from the browser cache while fresh messages find their way back.
Cache-first state ↗03Trust what comes in.
Validate messages, payloads, and parameters with your Standard Schema library. Keep the inferred types.
Runtime validation ↗04Room for interruption.
Backoff, jitter, and network recovery handle the gaps. Your listeners survive the reconnect.
Reconnection ↗02 / In practice
One client.
Your whole app.
Define an endpoint. Subscribe in a component.
Let the messages come to you.
// A client lives outside your components.
import { SocketClient } from "@ibnlanre/socket";
const prices = new SocketClient<string>({
baseURL: "wss://example.com",
url: "/prices",
retry: true,
});
// Each component gets a reactive snapshot.
export function PriceTicker() {
const { data } = prices.useSocket();
return <p>{data ?? "Waiting for price…"}</p>;
}The manual is open.
Find yourstarting point.