cf-socka-realtime

Enable real-time features over Durable Object WebSockets with Socka contracts.

10|Updated May 22, 2025
One-click install
npx skills add https://github.com/firtoz/cf-multiworker-starter-kit --skill cf-socka-realtime
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cf-socka-realtime
Source: https://github.com/firtoz/cf-multiworker-starter-kit/tree/main/agents/skills/cf-socka-realtime
Command: npx skills add https://github.com/firtoz/cf-multiworker-starter-kit --skill cf-socka-realtime

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Socka + Durable Object WebSockets—defineSocka, SockaWebSocketDO, useSockaSession, SSR-safe ws URLs, web worker forwarding, live-draft vs commit, canvas/whiteboard acceptance, and pre-merge checks. Use for realtime features, /api/ws, or @firtoz/socka.

Core Features & Use Cases

  • Define Socka contract (defineSocka) and its usage across the repo.
  • Durable Object extension SockaWebSocketDO to manage WebSocket DO wiring.
  • Web worker: upgrade path from client to DO websocket.
  • Client-side useSockaSession and URL integration for current host.
  • Route-safe wss / ws URL builder and SSR-safe URL handling.

Quick Start

Follow the Socka + DO pattern in this skill to wire a WebSocket endpoint and session management for a real-time collaboration feature.

Frequently Asked Questions about cf-socka-realtime

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up real-time WebSockets with Cloudflare Workers and Durable Objects?

To set up real-time WebSockets, you extend the SockaWebSocketDO Durable Object and use defineSocka to establish a contract. Web worker forwarding handles the upgrade path from client to DO WebSocket, enabling collaborative features with per-room state.

How do I make WebSocket URLs SSR-safe for a real-time collaboration app?

Making WebSocket URLs SSR-safe requires a route-safe URL builder that resolves the current host correctly during server-side rendering. This Skill provides client-side useSockaSession and URL integration to prevent SSR hydration mismatches.

Can I use Durable Object WebSockets for a canvas or whiteboard application?

Canvas and whiteboard applications are supported through live-draft vs commit messaging patterns over Durable Object WebSockets. The Socka contract manages per-room state and client-server messaging required for interactive collaborative drawing.

What is the best way to structure client-server messaging contracts for WebSockets?

Structuring WebSocket messaging contracts is best done using a reusable defineSocka pattern. This enforces typed client-server messaging, pre-merge checks, and consistent contract usage across your real-time application repository.

Does this WebSocket pattern work with standard /api/ws routing?

The Socka and Durable Object WebSocket pattern works with /api/ws routing. The web worker forwarding mechanism handles the client upgrade path to the Durable Object, ensuring proper routing for real-time features.