A real-time multiplayer math quiz game built with Next.js and Supabase. Players compete to solve math problems as quickly as possible in a live environment.
- Node.js (v18 or higher)
- npm or yarn
- Supabase account
- Clone the repository:
git clone <repository-url>
cd math-quiz- Install dependencies:
npm install- Set up environment variables:
Create a
.env.localfile in the root directory:
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key- Run the development server:
npm run dev- Open http://localhost:3000 in your browser.
math-quiz/
├── src/
│ ├── app/ # Next.js app directory
│ │ ├── api/ # API routes
│ │ ├── globals.css # Global styles
│ │ ├── layout.tsx # Root layout
│ │ └── page.tsx # Main page component
│ ├── components/ # React components
│ │ ├── HighScores.tsx # High scores display
│ │ ├── JoinForm.tsx # User join form
│ │ ├── Leaderboard.tsx # Live leaderboard
│ │ └── QuizInterface.tsx # Main quiz interface
│ ├── lib/ # Utility libraries
│ │ ├── answerService.ts # Answer submission logic
│ │ ├── notificationService.ts # Notification handling
│ │ ├── questionGenerator.ts # Math question generation
│ │ ├── questionService.ts # Question management
│ │ ├── supabase.ts # Supabase client
│ │ └── userService.ts # User management
│ └── types/
│ └── game.ts # TypeScript type definitions
├── public/ # Static assets
├── package.json # Dependencies and scripts
└── README.md # This file
- Frontend: Next.js 16, React 19, TypeScript
- Styling: Tailwind CSS
- Backend: Supabase (Database + Real-time)
- Deployment: Vercel (recommended)
- Real-time multiplayer: Multiple players can join and play simultaneously
- Dynamic question generation: Random math problems (addition, subtraction, multiplication, division)
- Live leaderboard: Real-time score tracking and ranking
- High score persistence: Scores are saved and displayed across sessions
- Responsive design: Works on desktop and mobile devices
- Real-time notifications: Instant feedback for correct/incorrect answers
- Players enter their username to join the game
- Math questions are generated automatically
- Players compete to answer questions correctly and quickly
- Scores are tracked in real-time on the leaderboard
- High scores are persisted and displayed
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLint