Repository navigation
WS1: the room on Workers - #2
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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