Skip to content

WS1: the room on Workers - #2

Merged
pullely merged 1 commit into
mainfrom
orun/WS-2-the-room-on-workers
Nov 11, 2026
Merged

pullely merged 1 commit into
mainfrom
orun/WS-2-the-room-on-workers

Conversation

@pullely

@pullely pullely commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

vercel/examples websockets/nitro (de86723) in apps/web as one Cloudflare Worker (cloudflare-worker-turbo). The React page, the wire protocol and the one defineWebSocketHandler at /api/ws are the template's, on its own Nitro 3.0.260610-beta, React 19 and Vite 8. vite.config.ts adds Nitro's cloudflare_durable preset (compatibilityDate 2026-10-01, cloudflare { deployConfig: false, nodeCompat: true }) and a plugin writing the site's name into index.html; vite build writes .output/server/index.mjs (with the preset's $DurableObject class) and .output/public, which the committed wrangler.jsonc names (nodejs_compat, Static Assets with ASSETS, the $DurableObject binding repeated in every env block — wrangler does not inherit it — and one new_sqlite_classes migration, so Workers Free runs it). The room's state moves to where a hibernating Durable Object keeps it: server/utils/presence.ts writes each identity into its socket's attachment beside crossws's own state and reads it back after a wake, and the roster is read from the live sockets instead of a module Map (crossws pinned to 0.4.6 workspace-wide). server/api/health.ts adds GET /api/health (the environment from the request's bindings), server/middleware/missing-file.ts answers a missing file with 404 instead of the page, shared/site.ts is the name seam, and the page's Vercel copy, logo and deploy button now describe Cloudflare (the footer still credits vercel/examples). tests/web drives the room through crossws's own Cloudflare adapter over a stand-in Durable Object: welcome, cursor fan-out and clamping, rejected frames, ping, leave, the identity in the attachment, and a simulated wake after which everything still works (it fails without the attachment). The starter's MIT licence is apps/web/LICENSE.md. The Worker is 14.6 KiB gzipped (Workers Free). typecheck, lint, test and build are green, and wrangler dev over the build serves the page, /api/health for its environment, a 101 handshake on /api/ws, and real clients see each other's joins, cursors, reactions and leaves before and after the room idles past a wake.

🤖 Generated with Claude Code

vercel/examples websockets/nitro (de86723) in apps/web as one Cloudflare Worker (cloudflare-worker-turbo). The React page, the wire protocol and the one defineWebSocketHandler at /api/ws are the template's, on its own Nitro 3.0.260610-beta, React 19 and Vite 8. vite.config.ts adds Nitro's cloudflare_durable preset (compatibilityDate 2026-10-01, cloudflare { deployConfig: false, nodeCompat: true }) and a plugin writing the site's name into index.html; vite build writes .output/server/index.mjs (with the preset's $DurableObject class) and .output/public, which the committed wrangler.jsonc names (nodejs_compat, Static Assets with ASSETS, the $DurableObject binding repeated in every env block — wrangler does not inherit it — and one new_sqlite_classes migration, so Workers Free runs it). The room's state moves to where a hibernating Durable Object keeps it: server/utils/presence.ts writes each identity into its socket's attachment beside crossws's own state and reads it back after a wake, and the roster is read from the live sockets instead of a module Map (crossws pinned to 0.4.6 workspace-wide). server/api/health.ts adds GET /api/health (the environment from the request's bindings), server/middleware/missing-file.ts answers a missing file with 404 instead of the page, shared/site.ts is the name seam, and the page's Vercel copy, logo and deploy button now describe Cloudflare (the footer still credits vercel/examples). tests/web drives the room through crossws's own Cloudflare adapter over a stand-in Durable Object: welcome, cursor fan-out and clamping, rejected frames, ping, leave, the identity in the attachment, and a simulated wake after which everything still works (it fails without the attachment). The starter's MIT licence is apps/web/LICENSE.md. The Worker is 14.6 KiB gzipped (Workers Free). typecheck, lint, test and build are green, and wrangler dev over the build serves the page, /api/health for its environment, a 101 handshake on /api/ws, and real clients see each other's joins, cursors, reactions and leaves before and after the room idles past a wake.

Co-Authored-By: Claude <noreply@anthropic.com>
Orun-Task: WS-2
@pullely
pullely merged commit 8bc00b0 into main Nov 11, 2026
2 checks passed
@pullely
pullely deleted the orun/WS-2-the-room-on-workers branch November 11, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants