Skip to content

Pocky

Shared virtual pet on a 3D island: two phones care for it in real time, it keeps living with the app closed and sends push notifications when it needs you.

Role
Fullstack Developer
Client
Personal project
Year
2026
Type
PWA
Stack
Next.js · Three.js · React Three Fiber · Firebase · TypeScript · PWA
Pocky

Context

Pocky is a Tamagotchi-style virtual pet for two people: both care for it from their own phone and see the same state instantly. It started as a 2D PWA and grew into a 3D island where Pocky walks on its own to the bowl, the pond, the play area or its bed depending on what you ask. Everything runs in the browser and installs without an app store.

Challenge

  • Two phones touching the same state at once without overwriting each other.
  • The pet has to get hungry or sleepy even when nobody has the app open.
  • Push notifications that actually arrive on iPhone (installed PWA) and Android, without spam.
  • A lively, smooth 3D scene on modest phones.
  • An honest offline mode: navigator.onLine lies.

Solution

  • Procedurally built 3D island with Three.js and React Three Fiber: house, trees, pond and paths. Pocky moves along a waypoint graph and the lighting follows the time of day.
  • Firestore with a persistent cache: the app boots with the latest data even offline. Every action runs in a transaction so two devices never clobber each other.
  • Anonymous Firebase Auth session + Firestore rules: nothing is read or written without a session.
  • 24/7 decay: an external cron hits a secret-protected Next.js route every 15 min that applies the same pure logic the client uses.
  • Push via Firebase Cloud Messaging: data-only messages drawn by the service worker (reliable on iOS, no duplicates), at most one every 4 h, with automatic cleanup of dead tokens.
  • Lower grass density on devices with 4 cores or fewer.

Result

  • Installs as an app on iPhone and Android straight from the browser, no store.
  • State is shared in real time between both phones and keeps going with the app closed.
  • Notifications arrive on iPhone and don’t pile up on Android.
  • Clearly tells you when what you do offline won’t be saved.

Gallery

Pocky — desktop view
Pocky — mobile view