Build real-time features without the headaches of WebSockets. Our SDK provides end-to-end type safety from schema definition to client interactions.
export const channels = sock8.channels({
'chat.{roomId}.messages': sock8.channels.rich({
schema: z.object({
message: z.string(),
sender: z.string(),
timestamp: z.number(),
}),
capabilities: {
history: true,
presence: z.object({
typing: z.boolean(),
online: z.boolean(),
}),
},
}),
});
TypeScript catches errors at compile time
// TypeScript catches errors
channels.chat.messages.for({ wrongParam: '123' })
// Error: Property 'wrongParam' does not exist.
// Expected property 'roomId' of type string.
channels.chat.messages.for({ roomId: '123' })
// ✓ Type check passed
Everything you need to build modern real-time applications with type safety at the core.
Create dynamic, scoped channels with path parameters. Perfect for multi-tenant apps and user-specific streams.
Track who's online, typing status, cursor positions, and more with just a few lines of code. Create truly collaborative experiences.
function Document() {
const { self, others, update } = usePresence(channel);
useEffect(() => {
// Update presence when cursor moves
window.addEventListener('mousemove', (e) => {
update({ cursor: { x: e.clientX, y: e.clientY } });
});
}, []);
}
Access recent messages on channel join with our built-in history capability. No need to implement separate storage or manage message caching.
// Access message history with a single hook
const { history } = useHistory(channel);
// Messages available immediately on join
Integrate with your existing auth system. Grant access to specific channels based on user identity and permissions with fine-grained control.
1
authorize: (conn) => {
2
conn.identifyAs(user.id);
3
conn.grant(channels.for({
4
userId: user.id
5
}));
6
}
Powered by Cloudflare Workers with Durable Objects and WebSocket Hibernation for incredible performance at any scale, anywhere in the world.
Join the waitlist for early access and be the first to build with sock8.