HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
cloudflare
workers-chat-demo
JavaScript2020–2024
cloudflare / workers-chat-demo

workers-chat-demo

Discover this repository through its Hacker News conversations.

9Distinct people
11Mentions
1Explicit recommenders
1.1KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A public description has not been verified.

Where it is used

No documented product use has been verified yet.

What people are saying

You can persist data with their edge stores (see the sibling comment), or use it to transpose between different API schemas, or as an API gateway that fetches consolidates,…

solardev used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year11 dated mentions

Observed mentions: 2020-09-28 13:23:59 UTC to 2024-10-14 07:04:43 UTC.

012342020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments20202021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments20222023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2024

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC312
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC404
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC202
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC000
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC202

What Hacker News says

11 sources
Cloudflare has a simple example of building real time chat using their infra: https://developers.cloudflare.com/workers/tutorials/deploy-a... (and source code for the actual app: https://github.com/cloudflare/workers-chat-demo) Doing this with serverless might be a lot easier than building the global network & edge infra on your own. But a real version would need to add a lot more, like auth, rotations (who on the merchant side is supposed to answer), status tracking, image management, linking to tickets and emails, etc. It's a lot of work. But it also sounds like it'll be core functionality for you guys, an integral part of a multi tenant B2C platform. Maybe you can start with a vendor solution for a few months, gauge reactions from both the merchants and their customers, and use that to inform whether to build your own (and what feature
Read the rest
s to add, if so?)
In Ask HN: How hard is it to build a B2C chat?
solardev·Aug 1, 2022Recommendation phrase
You can persist data with their edge stores (see the sibling comment), or use it to transpose between different API schemas, or as an API gateway that fetches consolidates, consolidates, and caches multiple micro-endpoints, or use it to run Doom (https://blog.cloudflare.com/doom-multiplayer-workers/) or IRC (https://github.com/cloudflare/workers-chat-demo) a variety of smaller useful things (https://developers.cloudflare.com/workers/examples/) I am not affiliated with Cloudflare, but Workers is by far my favorite cloud/serverless platform -- so much simpler and faster than Lambda, etc. (if your use case is simple enough)
In Running Zig with WASI on Cloudflare Workers
If you wanted something where you could get pretty far without spending any money, Cloudflare Workers + Durable Objects would be an interesting path. You would have to implement some of the functionality yourself, but there are some examples. Like this example chat app: https://github.com/cloudflare/workers-chat-demo/blob/master/... It supports private chat rooms, which is somewhat analogous to a pub sub topic.
In Ask HN: What's a global, low throughput, low latency message bus service?
> SSL is a solved problem since let's encrypt Only if you remember to update your cert chains, and your web servers have to keep up with TLS etc. updates too > cloudflare actually decreases performance (by adding an hop when serving dynamic content). If your dynamic content doesn't require true real-time updates (like a forum or chat or something), but can be limited to once a minute updates or similar (like a reddit-style front page), caching and global CDNs can still drastically speed that up for users who aren't near your data center. And that's just their static cache offering. If you build your site around their edge infrastructure (workers, workers KV, durable objects), you can entirely remove the last hop by handling client requests and sharing state across the CDN itself. Two of their demos show IRC-like chat and Doom (the game) r
Read the rest
unning entirely on the edge: https://github.com/cloudflare/workers-chat-demo https://blog.cloudflare.com/doom-multiplayer-workers/ They also do other performance boosts, like auto-optimizing images, converting to webp, minifying stylesheets & scripts, dynamic loading, http QUIC, etc. And they offer a edge streaming solution for video (although Vimeo is probably much cheaper for most use cases). > For most websites, DDoS attacks are a non-issue. It can also help with things like Google Analytics bot spam, drive-by vulnerability scans against certain web servers or Wordpress, etc. It's not just a IP blacklist but does some degree of traffic analysis. And all of that is available for free or cheap. It's very difficult to do all that yourself as a small-biz or solo web dev, even if you had full time dev-ops. As for "the internet shouldn't be controlled by a single entity", sure, but it's always been a corporate network. Choose your nemesis: Cloudflare, Google, Amazon, Facebook, Verisign/network solutions (in the old days)... there's never been a truly free internet. At least Cloudflare is doing a darned good job of stewarding the internet.
In OAuth with Cloudflare workers on a statically generated site
Durable Objects[0] let you store data on the edge and provide a lot more than a key/value store. This is a primitive you could build arbitrary databases on top of. The edge chat demo[1] is a working, scalable real-time chat service hosted entirely on the edge using Workers + Durable Objects, even featuring per-user cross-room rate limiting. As written, it can support millions of chat rooms and users, and it's about 500 lines of code.[2] The benefit here is that it's much easier to build scalable distributed systems on Workers and Durable Objects than on other platforms. The fact that they run on the edge as close to end users as possible is just a bonus. [0] https://blog.cloudflare.com/introducing-workers-durable-obje... [1] https://edge-chat-demo.cloudflareworkers.com/ [2] https://github.com/cloudflare/workers-chat-demo/blob/master/... (
Read the rest
Disclosure: I'm the tech lead for Cloudflare Workers.)
In Cloudflare’s Pace of Innovation
EDIT: Cloudflare already made a game demo on Workers... multiplayer Doom: https://blog.cloudflare.com/doom-multiplayer-workers/ that was written using WASM + WebSockets, porting over an open-source Doom and shimming in a UDP-over-Websockets networking layer. Despite all that, it's still fast enough for a first person shooter. Original post: Have you looked into using a serverless pub/sub model, like Cloudflare's Workers KV? The example they give is a simple IRC-like distributed chatroom (https://github.com/cloudflare/workers-chat-demo), but theoretically it may work for games too. Player state can be stored in a decentralized key-value store that Cloudflare manages (Cloudflare Durable Objects). They absorb all the DDoS and handle replication between edge nodes. You don't see any of that. https://developers.cloudflare.com/workers/learning/
Read the rest
using-dur... Then each game client uses a worker to access that KV on a subscription basis, and Cloudflare will route that worker to its nearest edge node and retrieve the state from there (which was previously replicated a moment ago, internal to Cloudflare's infrastructure). Changes to state are replicated across the edge network and pushed to client workers. https://workers.cloudflare.com/ I don't know if this would result in acceptable latency, but it could help with DDOS at least. The main benefit is that it's incredibly affordable, especially when you're only talking about thousands of players.
In DoS attacks against my online game
In short: the vendor (Cloudflare) handles it, not you. Cloudflare has to quickly disseminate a lot of things to their data centers all the time (new files, routing rules, cache invalidations, etc.) and Durable Objects piggybacks on that same infrastructure. From the client's point of view, all the network I/O is to a "centralized" server and not peer-to-peer, except in this case the "centralized" endpoint is actually a cluster of data centers that all talk to each other behind the scenes. Client --> nearest Cloudflare node --> all the other nodes via their phat pipes, not yours Edit: their global stateful serverless chatroom demo more clearly demonstrates how it works: https://github.com/cloudflare/workers-chat-demo
In Multiplayer Doom on Cloudflare Workers
WebSockets are a feature of Durable Objects. Workers handle WebSockets in a pretty straightforward way. The server-side API is literally the same WebSocket JavaScript API as in browsers. sock.addEventListener("message", callback), etc. But if you aren't using Durable Objects, then WebSockets on Workers aren't particularly useful, because there's no way to contact the specific Worker instance that is handling a particular client's WebSocket session, in order to send a message down. Durable Objects fixes exactly that. Now you can have worker instances that are named, so you can call back to them. Here's a complete demo that uses WebSockets to implement chat: https://github.com/cloudflare/workers-chat-demo/blob/main/ch... > Are they automatically terminated after the worker spends too much time active? We're still tweaking timeouts and limit
Read the rest
s, but in general you should be able to keep a WebSocket alive long-term, and reconnect any time it drops (which any WebSocket application has to do anyway, the internet being unreliable). > If so, doesn’t handling the WS handshake have a lot more overhead than a fetch call? Not sure what you mean here. A WS handshake in itself isn't terribly expensive. I suppose a typical application will have to establish some state after the socket opens, and that could be expensive, but it depends on the app.
In Durable Objects in Production
Demo chat application from the article using Durable Objects: - https://edge-chat-demo.cloudflareworkers.com - A Public Room (to joint test): hackernews - Source: https://github.com/cloudflare/workers-chat-demo Insanely awesome feature add (much needed for truly “serverless” application development). The power to scale here without insane infrastructure headache is amazing. One day some kid is totally going to build a single-person billion dollar company from his mom’s basement.
In Workers Durable Objects Beta: A New Approach to Stateful Serverless

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.