Behind the Scenes of My First Web Lens
How I engineered a 60fps Canvas game under 8 MB with @snap/web-lens-api leaderboards, safe-area HUDs, and instant browser play.
Snapchat Web Lenses unlock something magical: full HTML5 Canvas and WebGL games that launch inside Snapchat without needing a camera feed—and run just as smoothly inside a mobile browser viewport on this portfolio.
1. Respecting Snapchat Safe Areas & Carousel UI
In full-screen play, Snapchat overlays its close button in the top-left 64 × 64 CSS pixel corner. Placing score pills on the right edge and keeping interactive tap targets safely inside the middle arena ensures zero accidental exits during fast reflex runs.
Vite Build → Unbundled snap-api.js → 10 KB Production ZIP
2. Leaderboards & Persistent Best Scores
Integrating @snap/web-lens-api lets the game call snapchat.leaderboards.submitScore({ score }) as soon as a 20-second run ends, while storing personal high scores via snapchat.storage instead of localStorage.