A classic Tetris game built with Next.js and Supabase.
- User authentication (login/register)
- Classic Tetris gameplay
- Real-time score tracking
- Global leaderboard (Top 10)
- Each user keeps only their highest score
- Frontend: Next.js 16, React, TypeScript, Tailwind CSS
- Backend: Supabase (Auth + Database)
- Clone the repository:
git clone https://github.com/chenwenxiaolive/tetris.git
cd tetris- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env.localEdit .env.local with your Supabase credentials:
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
- Run the development server:
npm run dev| Key | Action |
|---|---|
| Left/Right Arrow | Move piece |
| Up Arrow | Rotate piece |
| Down Arrow | Soft drop |
| Space | Hard drop |
CREATE TABLE scores (
id UUID PRIMARY KEY,
user_id UUID UNIQUE REFERENCES auth.users(id),
username TEXT,
score INTEGER,
created_at TIMESTAMP
);MIT