Hi, I'm hakairyuousinn (my X account).
My browser games now show the player's result as an image card on X. I didn't build anything that draws OGP images on a server. The game has already drawn the result, so the browser turns it into a PNG and the server just stores it. The storage side is Cloudflare Workers and R2, and every game I've published uses it.
- When the share button is pressed on the result screen, the game makes a 1200×630 PNG
- It sends the PNG and the result fields (score and so on) to a Worker on my site
- The Worker checks the fields, puts the image and a small card HTML page into R2, and returns the URL of that page
- The game opens X's post screen with that URL
The link that opens X's post screen can't carry an image. It only takes text and a URL. So for each share, I make one HTML page whose og:image is the result image, and pass that page's URL. When someone taps the card, that page sends them on to the game.

The text on the card and where it leads are decided on the server. The fields sent from the game are checked for length and format before they're used. I don't want people making cards with whatever text they like.
Over half of Rokuro's visitors came from shares
The first game to get this was Rokuro, where you make a pot on a pottery wheel and get it appraised (November 1). By the next day, November 2, 7,597 of the 13,248 people who came to Rokuro had arrived through someone's share link.
Share links carry a ?ref=share tag, and my analytics counts how many times a page opens with it.
That number includes one post that spread really widely, though. I don't expect every game to do this...
Rebuilt so it won't stop on a big day
The first version ran the viewing side through the Worker too. To keep pranks from running up costs, it also had a limit on how many cards could be made per day.
The next day I realized this was a problem. The Workers free plan has a cap on how many times a Worker can run per day. If the Worker runs every time a card is viewed, the more something gets shared, the closer it gets to that cap. The card would stop showing on exactly the day it matters most...
So I connected R2 to a subdomain (s.hakairyuousinn.com) and serve the HTML and image straight from there. The Worker only runs when a card is made. I also raised the daily limit a lot.
What tripped me up after the rebuild was caching. With Cloudflare's default settings, HTML without a file extension wasn't cached. Adding one rule fixed it. R2 doesn't stop when you go over the free tier, it just bills you, so images are set to delete after 180 days.
Sharing from a PC didn't show the card
This is what I fixed today (November 8). When sharing from a PC, the post showed a quote of my announcement post instead of the result card.
The share text had the card URL, followed by the URL of the announcement I'd posted on X. I wanted people to see the announcement too. But when a post ends with a post URL, X shows only that quote and drops the card.
The fix was simple: if the card URL comes back, don't add the announcement. Only when sending the image fails does it fall back to the game's plain URL plus the announcement quote. I fixed it in Chez Weeds first and published it.
Phones work differently. The share screen attaches the image itself, with the text and the announcement quote.
When sending is slow, and opening on iPhone
The game waits up to 8 seconds for the upload. If it takes longer or fails, it passes the game's plain URL without a card. That's better than the share not working at all.
Also, the moment the share button is pressed, an empty tab opens first. When the URL comes back, that tab turns into X's post screen. On iPhone, opening a new tab after waiting for the reply gets blocked.
I wrote about the games themselves in the posts on Rokuro and Chez Weeds.