This is my month 1 sketchbook with PartyKit. I’ve long been interested in how the internet goes multiplayer... everything from AI NPCs to architecture to ambient togetherness. Technically, these are hard problems.

PartyKit is a new startup that solves multiplayer. Coding with it, I feel like I’m rewiring the internet from the inside. As inventor in residence my goal is to bring some of these multiplayer ideas to life — and, by being embedded, bend PartyKit's platform in this direction too.

Month 1 (Jul–Aug 2023) was about me getting to know the platform. These are a few of the sketches I made.

Voronoi cursors demo code

This sketch shows the cursors of everyone connected to the webpage, in realtime. A Voronoi diagram dances in the background based on their positions. The cursors are decorated with their flag of origin: you get that for free because everything runs through Cloudflare's global network.

It's neat to look at the code and see how simple this is. I began to feel like I was writing an object class - a neatly encapsulated tiny bundle of wiring - that, when instantiated as a "room", would float ~~somewhere~~ and infinitely remember, re-broadcast, and reply, a minuscule multiplayer machine whirring away.

Tiny garden demo code

I tried two things with this sketch. First it makes use of Yjs (Yjs implements shared data-structures called CRDTs. CRDTs are the underlying tech of apps like Google Docs and Figma that allow for realtime collaboration). Running a Yjs server is a one-liner with PartyKit.

Next: could the document evolve independently of users? My example here is a garden: you plant a seed and it changes to a sprout, tree, logs, and so on until it finally disappears, but you could imagine any kind of simulation. The garden grows on the server, so long as at least one client is connected. That's interesting: PartyKit isn't just wiring, it's also a block of code that users can't touch but can none-the-less collaborate with. You could use that for managing an auth server, or maybe something else.

A mosaic challenge demo code

Remember that "wisdom of the crowd" demo where you get a ton of people to make a picture, one pixel at a time, given a text description to aim at? I built this in an hour and tested that idea — it takes about 2,000 turns to converge on a 15x15 grid.

In theory this should be able to support many, many simultaneous connections (like >1,000) because the PartyKit "object" can hold the websocket connections open and hibernate them when there's no traffic. I‘m interested in how to have many inbound messages consolidated to a small number of outbound messages, in order that you can have a sense of online togetherness to a very large number of people.

Live polls for static web pages code

I’m interesting in making regular, static websites more social, more alive. The way to do this is using Web Components, a web standard that lets you make new HTML tags with any functionality you can imagine. I’m using Stencil to help build this components.

This is a poll. You don‘t need to do any server configuration. You just write the poll in the HTML and it automatically makes a new “room” to store the results. Results update for all users in realtime.

Two-way hyperlinks and social webpages code

More web components! One component badges all internal links on a site with how many people are present at the other end. Another tells you if a hyperlink has been used, in realtime, while you're using the page. A third adds multiplayer cursors to any webpage, as if the cursors are sitting behind the content, through frosted glass.

(The cursors are running on this webpage. You can install them too! Check out the README.)

I’m into the idea that basic multiplayer is super straightforward, and that we might have a whole collection of standard, ambient presence components like this. And then more complex ideas become possible to imagine.

A few more links

I mentioned I’ve been looking at multiplayer for a while. In particular do check out: