I built a daily co-op puzzle for the Game of the Day hackathon and kept notes on what actually saved me time. Sharing in case it helps someone still building before the deadline.
1.Race-free daily rules without Redis transactions
Give every "once per player" fact its own guard that is a single atomic command:
- Has this player joined today? hSetNX day:side <user> <side> (first write wins).
- Has this player submitted? hSetNX day:p:<user> submitted <json>, and only update totals if it returned 1.
- How many attempts? hIncrBy day:p:<user> attempts 1, and refuse if the returned number is over the limit. Two tabs get two different numbers, never the same one.
Then have every endpoint return the player's whole state and let the client replace what it had. Double taps, retries and a second tab can't disagree.
2. Let the post be the day
When the scheduler creates the post, put the puzzle's date in postData. The server reads the date from context.postData, never from the clock or the request. Old posts keep playing their own puzzle, and nobody gets tomorrow's by changing a parameter. Also reject a post date in the future on the server.
3. Create the daily post exactly once
The scheduler, the install trigger and a mod menu item can all end up calling "post today's puzzle". Guard it with hSetNX posts <date> pending: only the caller that gets 1 creates the post, then stores the post id. If creating fails, delete the field so the next run can try again.
4. Test your server without uploading
Put everything Reddit-specific (Redis, user id, postData, submitPost, flair) behind one small interface your routes take as a parameter. In production pass the Devvit objects; in tests and a local preview pass an in-memory fake. You can then run the real routes with Node's test runner, including concurrent requests with Promise.all, and preview every screen in a normal browser.
5. Fit the inline card to the feed
On my phone the inline post (regular height) was 512px tall, but in mobile Chrome only about 450px of it is on screen under the subreddit header. Keep your main button, and anything you want seen like a streak, in the top ~440px, and check it on a real phone, not just the playtest view. Also plan for big numbers early: a count like 1237035 will burst a small box, so show 1.2M and keep the exact number in an aria-label.
6. Two small TypeScript / Windows gotchas
- "No exported member" from @devvit/web/client: the package resolves differently for browser and server. Type-check client code with "customConditions": ["browser"] and server code without it (two tsconfig files).
- On Windows, if PowerShell says scripts are disabled, use npx.cmd devvit ... If devvit login fails with EADDRINUSE :65010, an earlier login is still waiting in another terminal; close it.
Happy to answer questions about any of these. If you want to see them in action, my entry is r/DuoluneDaily (you hold half of a daily puzzle, the rest of the subreddit holds the other half).