A real-time multiplayer typing game built with Next.js and Socket.IO.
- Solo Mode: Practice typing alone with timer and stats
- Multiplayer Mode: Race against friends in real-time
- Real-time WPM and accuracy tracking
- Live player progress visualization
- Custom room system for private matches
- Responsive design with Tailwind CSS
donkeytype/
βββ client/ # Next.js frontend application
β βββ public/ # Static assets
β β βββ logo.png # App logo
β βββ src/
β β βββ app/ # Next.js App Router pages
β β β βββ (solo)/ # Solo mode (root route)
β β β β βββ page.js # Solo typing game
β β β βββ multiplayer/ # Multiplayer mode
β β β β βββ page.js # Multiplayer typing game
β β β βββ chart/ # Stats visualization
β β β β βββ page.js # Chart display page
β β β βββ globals.css # Global styles
β β β βββ layout.js # Root layout
β β β βββ page.js # Home page wrapper
β β β βββ providers.js # App providers
β β βββ components/
β β β βββ chart.jsx # Chart component
β β β βββ navbar.js # Navigation bar
β β β βββ multi/ # Multiplayer components
β β β β βββ Chat.js
β β β β βββ GameSettings.js
β β β β βββ PlayerCard.js
β β β β βββ ResultSummary.js
β β β β βββ TypingArea.js
β β β βββ solo/ # Solo mode components
β β β β βββ InputBar.js
β β β β βββ restartButton.js
β β β β βββ result.js
β β β β βββ typing.js
β β β βββ ui/ # UI components (shadcn/ui)
β β β βββ card.jsx
β β β βββ chart.jsx
β β β βββ resizable-navbar.jsx
β β β βββ select.jsx
β β βββ contexts/
β β β βββ SocketContext.js # Socket.IO context provider
β β βββ hooks/
β β β βββ countdownTimer.js # Timer hook
β β β βββ usetyping.js # Typing logic hook
β β βββ lib/
β β β βββ utils.js # Utility functions
β β βββ services/
β β βββ helper.js # WPM/accuracy calculations
β βββ .env.local # Environment variables (Socket URL)
β βββ .env.example # Environment variables template
β βββ components.json # shadcn/ui config
β βββ eslint.config.mjs # ESLint configuration
β βββ next.config.mjs # Next.js configuration
β βββ postcss.config.mjs # PostCSS configuration
β βββ tailwind.config.mjs # Tailwind CSS configuration
β βββ package.json # Frontend dependencies
β
βββ server/ # Socket.IO backend server
β βββ server.js # Socket.IO server implementation
β β # - Room management
β β # - Real-time game state sync
β β # - Player progress tracking
β β # - Chat functionality
β βββ .env # Server environment variables
β βββ .env.example # Environment variables template
β βββ .gitignore # Git ignore rules
β βββ package.json # Backend dependencies
β
βββ DEPLOYMENT.md # Deployment guide
βββ README.md # This file
- Next.js 15.1.6 - React framework with App Router
- React 19 - UI library
- Socket.IO Client - Real-time communication
- Tailwind CSS - Styling
- Motion - Animations
- Recharts - Data visualization
- shadcn/ui - UI components
- Faker.js - Random word generation
- Node.js - Runtime environment
- Express - Web server
- Socket.IO - Real-time bidirectional communication
- dotenv - Environment variable management
- Node.js 18+ installed
- npm or yarn package manager
- Clone the repository
git clone https://github.com/tejash111/donkeytype.git
cd donkeytype- Install server dependencies
cd server
npm install- Install client dependencies
cd ../client
npm installYou need to run both the server and client simultaneously.
Client (.env.local):
NEXT_PUBLIC_SOCKET_URL=http://localhost:4000Server (.env):
PORT=4000
CORS_ORIGIN=*
NODE_ENV=developmentTerminal 1 - Start Socket.IO Server:
cd server
npm run devβ
Server runs on http://localhost:4000
Terminal 2 - Start Next.js Client:
cd client
npm run devβ
Client runs on http://localhost:3000
Server:
cd server
npm install
node server.jsClient:
cd client
npm install
npm run build
npm start- Navigate to
http://localhost:3000/(root page) - Choose between time or words mode
- Select duration (15s, 30s, 1m, 2m) or word count (10, 25, 50, 100)
- Start typing when ready
- View your WPM, accuracy, and detailed stats after completion
- Navigate to
http://localhost:3000/multiplayer - Enter your username
- Create Room: Click "create room" to generate a 6-character room code
- Join Room: Enter the room code shared by a friend
- Wait for other players (only room creator can start)
- Room creator can adjust settings (time limit, word count, game mode)
- Click "Start" to begin the race
- Type the words - see live progress of all players!
- Check the leaderboard and WPM charts when finished
join-room- Join/create a multiplayer roomstart-game- Start the typing game (creator only)update-progress- Update player's WPM, accuracy, progressupdate-settings- Change game settings (creator only)player-ready- Mark player as readychat-message- Send chat messagetime-up- Notify when time expiresleave-room- Leave the current room
room-state- Initial room state with players and settingsplayer-joined- New player joined with updated player listplayer-left- Player disconnectedgame-started- Game begins with words and start timeprogress-update- Real-time player progress updatesgame-finished- Game ended with final resultssettings-updated- Game settings changed by creatorplayer-ready-update- Player ready status changednew-chat-message- New chat message receivederror- Error messages
This project is licensed under the MIT License - see the LICENSE file for details.
Change in server/server.js:
const PORT = 4000; // Change thisChange in client/src/contexts/SocketContext.js:
const socketInstance = io("http://localhost:4000", {
// Change URL
transports: ["websocket"],
});- Make sure the Socket.IO server is running on port 4000
- Check if another application is using port 4000
- Verify the URL in SocketContext.js matches your server
- Run
npm installin bothclient/andserver/directories - Delete
node_modulesand reinstall if issues persist
- Kill the process using the port:
# Windows
netstat -ano | findstr :4000
taskkill /PID <PID> /F
# Mac/Linux
lsof -ti:4000 | xargs kill -9- Frontend changes go in
client/src/ - Backend/Socket.IO logic goes in
server/server.js - Shared types/interfaces can be documented in comments
- Components:
client/src/components/ - Pages:
client/src/app/*/page.js - Hooks:
client/src/hooks/ - Utils:
client/src/services/
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is open source and available under the MIT License.
Tejash
- GitHub: @tejash111
Give a βοΈ if you like this project!