Every December, virtual Christmas wish-tree apps go viral on Instagram Stories and WhatsApp: you plant a digital pine tree, friends hang ornaments containing secret holiday messages, and everything stays locked until December 25.
I wanted to see how fast and lightweight I could build one—zero login wall, real server-side message locking, smooth visual evolution, and single-tap 9:16 story poster export—so I shipped Decorate My Tree Online on Cloudflare Workers + D1.
Here are the architectural decisions that mattered most.
1. Real Server-Side Time-Lock (No DevTools Spoilers)
A common shortcut in seasonal greeting apps is fetching all messages to the browser and hiding them behind a CSS blur until December 25. One peek in the Network tab ruins the surprise.
Instead, the Cloudflare Worker checks Date.now() < Date.parse(env.UNLOCK_AT) on every GET /api/trees/:id response and strips the message body completely on the server:
const isUnlocked = now >= unlockAtMs || tree.unlocked_all === 1 || gift.peeked === 1 || isSender; return { id: gift.id, senderName: gift.sender_name, boxStyle: gift.box_style, locked: !isUnlocked, message: isUnlocked ? gift.message : null, }; Until Christmas morning (or an explicit per-gift unlock), the browser only receives message: null.
2. Zero-Login Auth with Hashed Browser Tokens
Asking a friend to create an account before leaving a 2-sentence Christmas note kills conversion immediately.
- Tree owners generate a random 48-char
ownerTokenon tree creation. D1 stores only its SHA-256 digest (owner_token_hash), while the browser keeps the raw token inlocalStorage. - Gift senders get a scoped
senderTokenso they can review the note they just hung without seeing anyone else's. - All token and webhook comparisons use Web Crypto constant-time verification (
crypto.subtle.timingSafeEqual) inside the Worker.
3. Client-Side 96×96 Avatar Lockets (Zero Object Storage Cost)
Friends love attaching a selfie or holiday emoji to their ornament. Instead of wiring up signed S3/R2 uploads for tiny thumbnails, the frontend draws any uploaded photo onto an offscreen 96×96 canvas, center-crops it to a circle, and exports a compact JPEG data URL (~8–15 KB, validated strictly server-side).
4. Three-Tier Visual Progression + 60fps Canvas VFX
To give people a clear reason to share their tree link, the scene evolves automatically as ornaments accumulate (detailed in the Christmas Wish Tree Guide):
- 0–4 gifts (Tier 1): Sculpted 5-layer winter pine under a crescent moon
- 5–11 gifts (Tier 2): Warm glowing bokeh fairy lights, parallax snowfall, and snowdrifts
- 12+ gifts (Tier 3): Flowing 60fps Canvas Northern Lights aurora ribbons and a radiant Golden Star topper
For sharing, an offscreen 1080×1920 Canvas renderer generates a ready-to-post 9:16 Instagram Story PNG right in the browser—no headless Chrome server needed.
5. Dual Payment Checkout on Workers (Stripe + Dodo Payments)
Everything core (planting a tree, hanging gifts with avatars, downloading story posters, unlocking themes by inviting 3 friends, and opening every wish on Dec 25) is free. Optional one-time digital upgrades ($1.99–$4.99) run through both Stripe Checkout and Dodo Payments using pure fetch() + Web Crypto HMAC webhook verification—keeping the entire Worker bundle around 8 KiB gzipped with ~1 ms cold start.
If you want to inspect the live interactive tree or leave a test wish on mine (currently at 5/12 gifts), here is a live demo link:
Happy to answer any questions about running Cloudflare Workers + D1, Canvas aurora effects, or Web Crypto webhook verification!