Note: This project was fully vibe coded with Claude Code.
A real-time multiplayer dice game built with Next.js and WebRTC. Players take turns rolling dice with decreasing ranges until someone rolls a 1 and loses. Features team mode, statistics tracking, smart reconnection, and PWA support.
- ๐ฎ Real-time Multiplayer - Peer-to-peer gaming using WebRTC (no server needed!)
- ๐ฅ Flexible Team Mode - Any team combination (1v2v3, 2v2, 1v1v1, etc.)
- ๐ Statistics Dashboard - Track wins, losses, streaks, and achievements
- ๐ Smart Reconnection - Auto-reconnect with network quality indicator
- ๐ฑ PWA Support - Install on mobile/desktop, works offline
- โก Real-time Sync - State synchronization across all players
- ๐จ Custom Avatars - Emoji avatars and color themes for each player
- โจ๏ธ Keyboard Shortcuts - Space/Enter to roll dice
# Install dependencies
npm install
# Run development server
npm run dev
# Open http://localhost:3000# Build static export
npm run build
# Output in ./out directory-
Host a Game
- Click "Host Game"
- Share the room code with players
- Configure teams (optional)
- Start the game when everyone joins
-
Join a Game
- Click "Join Game"
- Enter the room code
- Choose your name and avatar
- Wait for host to start
-
Gameplay
- First roll: 1-100
- Each subsequent roll: 1-(previous result)
- Roll a 1 โ You lose!
- Last player standing wins
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- WebRTC: PeerJS
- PWA: Service Workers + Web App Manifest
- State: React Hooks + Context
Deploy to GitHub Pages, Vercel, Netlify, or Cloudflare Pages:
# GitHub Pages (automatic via Actions)
git push origin main
# Vercel
vercel --prod
# Netlify
netlify deploy --prod --dir=outSee DEPLOYMENT.md for detailed deployment instructions.
After deployment:
- Visit your app URL in Chrome/Edge
- Look for "Install app" prompt
- Or: Menu โ "Add to Home Screen"
- App works offline after first visit
Improve connection reliability (85% โ 99%) by configuring a TURN server:
# .env.local
NEXT_PUBLIC_TURN_URL=turn:your-server.com:3478
NEXT_PUBLIC_TURN_USERNAME=username
NEXT_PUBLIC_TURN_CREDENTIAL=passwordFree TURN providers: Metered.ca, Twilio
For GitHub Pages at username.github.io/repo-name/:
NEXT_PUBLIC_BASE_PATH=/repo-name npm run buildTrack your performance at /stats:
- Win/loss record and win rate
- Current and longest streaks
- Total rolls and average roll
- Achievements (Fastest Win, Comeback, etc.)
- Global leaderboard
- Export/share stats
- 2-8 players
- Last player standing wins
- Create any team combination
- 1v2v3, 2v2, 3v3, etc.
- Teams share turns
- Eliminate entire team when any member rolls 1
- Auto-reconnect on network drop
- Network quality indicator (excellent/good/poor)
- State persistence survives page refresh
- Exponential backoff prevents spam
- Manual retry after failed attempts
deathroll/
โโโ src/
โ โโโ app/ # Next.js app routes
โ โ โโโ page.tsx # Home page
โ โ โโโ host/ # Host game page
โ โ โโโ play/ # Join game page
โ โ โโโ stats/ # Statistics dashboard
โ โโโ components/ # React components
โ โ โโโ game/ # Game-specific UI
โ โ โโโ ui/ # Reusable UI components
โ โ โโโ pwa/ # PWA components
โ โโโ hooks/ # React hooks
โ โ โโโ useHostGame.ts
โ โ โโโ usePlayerGame.ts
โ โโโ lib/ # Core logic
โ โ โโโ game/ # Game rules & state
โ โ โโโ peer/ # WebRTC peer management
โ โ โโโ statistics.ts # Stats tracking
โ โ โโโ storage.ts # LocalStorage helpers
โ โโโ types/ # TypeScript types
โโโ public/ # Static assets
โ โโโ manifest.json # PWA manifest
โ โโโ sw.js # Service worker
โ โโโ icons/ # App icons
โโโ scripts/ # Build scripts
Contributions welcome! Please feel free to submit a Pull Request.
MIT License - feel free to use this project for anything!
Play now: https://Dasio.github.io/deathroll/
Built with โค๏ธ using Next.js, WebRTC, and good vibes