# chvin/react-tetris

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/chvin-react-tetris).**

8,717 stars · 2,277 forks · JavaScript

## Links

- GitHub: https://github.com/chvin/react-tetris
- Homepage: https://chvin.github.io/react-tetris/?lan=en
- awesome-repositories: https://awesome-repositories.com/repository/chvin-react-tetris.md

## Topics

`immutable` `react` `redux` `tetris`

## Description

This is a browser-based Tetris game built with React, using Redux and Immutable.js to manage all game state in a single immutable store. The application renders the game board, next-block preview, and score display as React components, with state transitions that are predictable and support time-travel debugging through the Redux DevTools Extension.

The game distinguishes itself through several integrated capabilities. It automatically adapts between keyboard and touch controls based on the user's input device, with configurable repeat rates for responsive gameplay. A persistence layer serialises the full Redux state tree to localStorage, restoring progress on page reload for session continuity. The game also pauses its loop when the browser tab loses focus and resumes on regaining visibility, and plays precise audio cues using the Web Audio API from a single MP3 file.

Additional capabilities include a next-block preview, score and level tracking, and the ability to toggle sound and pause at any time. The interface language can be switched by reading a URL query parameter, with translations defined in a bundled JSON file.

## Tags

### Game Development

- [Puzzle Games](https://awesome-repositories.com/f/game-development/browser/puzzle-games.md) — Plays the classic block-stacking puzzle in a web browser with keyboard and touch controls, scoring, and increasing difficulty levels.
- [Falling Block Puzzles](https://awesome-repositories.com/f/game-development/open-source-games/genres/puzzle-games/falling-block-puzzles.md) — Controls a falling block puzzle game where players rotate and position shapes to complete horizontal lines. ([source](https://chvin.github.io/react-tetris/))
- [Role-Play Gameplay Mechanics](https://awesome-repositories.com/f/game-development/role-play-gameplay-mechanics.md) — Renders the classic block-stacking puzzle with keyboard and touch controls, scoring, and increasing speed levels. ([source](https://cdn.jsdelivr.net/gh/chvin/react-tetris@master/README.md))
- [Save Game Initialization](https://awesome-repositories.com/f/game-development/save-game-initialization.md) — Saves the full game state to localStorage so progress is restored after a page refresh, crash, or phone call. ([source](https://cdn.jsdelivr.net/gh/chvin/react-tetris@master/README.md))
- [Score Tracking Systems](https://awesome-repositories.com/f/game-development/score-tracking-systems.md) — Tracks and displays current score, cleared lines, and level progression during gameplay. ([source](https://chvin.github.io/react-tetris/?lan=en))
- [Browser Local Storage Saves](https://awesome-repositories.com/f/game-development/save-game-initialization/browser-local-storage-saves.md) — Saves and restores full game state to localStorage so progress persists across page reloads.
- [Web Game Audio Engines](https://awesome-repositories.com/f/game-development/web-retro-environments/web-game-audio-engines.md) — Plays precise audio cues using the Web Audio API from a single MP3 file during gameplay.
- [Web Audio API Sound Engines](https://awesome-repositories.com/f/game-development/web-retro-environments/web-game-audio-engines/web-audio-api-sound-engines.md) — Plays precise, high-frequency audio cues using the Web Audio API for real-time game feedback.

### Web Development

- [Game Implementations](https://awesome-repositories.com/f/web-development/react-application-development/game-implementations.md) — A classic block-stacking puzzle game implemented as a single-page React application with keyboard and touch support.

### Part of an Awesome List

- [Immutable Data Structures](https://awesome-repositories.com/f/awesome-lists/devtools/immutable-data-structures.md) — Uses Immutable.js persistent data structures to prevent accidental mutation and simplify state comparison.
- [Device-Aware Input Switching](https://awesome-repositories.com/f/awesome-lists/devtools/input-and-controllers/controller-input-mappers/device-aware-input-switching.md) — Automatically switches between keyboard and touch controls based on the user's input device.

### Data & Databases

- [Game State Persistence](https://awesome-repositories.com/f/data-databases/game-state-persistence.md) — Saves and restores the full game state across browser sessions using localStorage to prevent progress loss.
- [LocalStorage Persistence](https://awesome-repositories.com/f/data-databases/state-persistence-layers/localstorage-persistence.md) — Serialises the full Redux state tree to localStorage, restoring progress on page reload for session continuity.

### Development Tools & Productivity

- [Game Keyboard Controls](https://awesome-repositories.com/f/development-tools-productivity/keyboard-interaction-controls/game-keyboard-controls.md) — Uses keyboard keys to rotate, move, drop, and reset blocks during gameplay. ([source](https://chvin.github.io/react-tetris/?lan=en))
- [Game Audio and Pause Toggles](https://awesome-repositories.com/f/development-tools-productivity/notification-command-line-tools/sound-and-notification-toggling/game-audio-and-pause-toggles.md) — Provides in-game buttons to mute audio and pause or resume the game at any time. ([source](https://chvin.github.io/react-tetris/?lan=en))

### Software Engineering & Architecture

- [Predictable State Containers](https://awesome-repositories.com/f/software-engineering-architecture/predictable-state-containers.md) — Manages all game state in a single immutable Redux store for predictable state transitions and time-travel debugging.
- [Game State Stores](https://awesome-repositories.com/f/software-engineering-architecture/redux-implementations/game-state-stores.md) — Manages all game state in a single immutable Redux store with Immutable.js for predictable transitions.
- [Redux Store Inspection](https://awesome-repositories.com/f/software-engineering-architecture/redux-implementations/distributed-state-stores/redux-store-inspection.md) — Exposes the entire game state to the Redux DevTools Extension for debugging and inspection. ([source](https://cdn.jsdelivr.net/gh/chvin/react-tetris@master/README.md))

### User Interface & Experience

- [Cross-Device Input Handlers](https://awesome-repositories.com/f/user-interface-experience/cross-device-input-handlers.md) — Switches between keyboard and touch controls automatically based on the user's input device for seamless gameplay.
- [Keyboard and Touch Adapters](https://awesome-repositories.com/f/user-interface-experience/input-handling/mobile-touch-handlers/keyboard-and-touch-adapters.md) — Automatically switches between keyboard and touch controls based on device detection with configurable repeat rates.
- [Component-Based Rendering](https://awesome-repositories.com/f/user-interface-experience/node-based-ui-components/component-based-ui-integrations/component-based-rendering.md) — Renders the game board, next-block preview, and score as React components driven by Redux state.
- [Game Block Previews](https://awesome-repositories.com/f/user-interface-experience/form-builders/builder-block-previews/game-block-previews.md) — Shows the upcoming block in a dedicated area so the player can plan placements ahead of time. ([source](https://chvin.github.io/react-tetris/?lan=en))
- [Automatic Device Detection](https://awesome-repositories.com/f/user-interface-experience/touch-to-desktop-input-mappers/automatic-device-detection.md) — Switches between keyboard input on desktop and touch input on mobile automatically. ([source](https://github.com/chvin/react-tetris/blob/master/README-EN.md))

### Graphics & Multimedia

- [Sound Effects Playback](https://awesome-repositories.com/f/graphics-multimedia/sound-effect-libraries/sound-effects-playback.md) — Uses the Web Audio API to play precise, rapid audio cues from a single MP3 file during gameplay. ([source](https://cdn.jsdelivr.net/gh/chvin/react-tetris@master/README.md))
