Skip to content

LabinatorSolutions/stockfish-chess-web-gui

Stockfish Chess Web GUI

GUI Type JavaScript Stockfish 18 Chess Engine License

A modern, responsive, and fully functional web-based chess application powered by the Stockfish 18 engine.


πŸ“– Table of Contents


Overview

It is a web graphical user interface (GUI) for the Stockfish Chess engine. It allows you to play against one of the strongest chess engines in the world directly in your browser, with professional-grade analysis tools and a highly customizable interface.


Mission

Our mission is to develop a modern, responsive, free, and open-source web-based chess GUI that brings the power of Stockfish to everyone, anywhere, on any device.


Features

  • Multi-Mode Gameplay:

    • vs. Stockfish (Engine): Play against the engine with customizable strength.
    • Local PvP (Pass-and-Play): Two players on the same device.
    • Side Swap: Switch colors mid-game; the board flips and the engine takes over the other side instantly.
    • Analysis Mode: Infinite analysis for post-game review.
  • Board & Piece Customization:

    • 12 Board Themes: Brown Wood, Red Wine, Green Forest, Blue Sky, and more, optimized for eye comfort.
    • Piece Sets: Choose between Standard and Staunty sets.
    • Persistent Settings: Your preferences are automatically saved in local storage.
  • Advanced Analysis Tools:

    • Multi-threaded Analysis: Leverage your CPU's power (requires COOP/COEP headers).
    • Customizable Engine Parameters: Adjust Skill Level (1-20), Elo Rating, Fixed Depth (1-36), and Thinking Time.
    • Visual Aids: Hint button for best-move visualization and a toggleable analysis arrow.
    • Real-time Eval: Display real-time evaluation and the top 2 Principal Variations (PVs).
    • Annotations: Right-click to draw arrows and markers on the board.

Tech Stack

  • Bun: Fast runtime, package manager, and native bundler.
  • Biome: Ultra-fast linter and formatter.
  • cm-chessboard: High-quality chessboard visualization.
  • chess-console: Robust game logic and state management.
  • Stockfish.js / cm-engine-runner: Seamless chess engine abstraction.
  • Bootstrap 5: Responsive UI styling.

Project Structure

β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Config.js                # Core app and engine configuration
β”‚   β”œβ”€β”€ CustomStockfishRunner.js # Engine communication layer
β”‚   β”œβ”€β”€ StockfishAnalysis.js     # Analysis mode logic
β”‚   β”œβ”€β”€ StockfishGameControl.js  # UI-to-engine bridge
β”‚   β”œβ”€β”€ StockfishNewGameDialog.js# Game setup modal
β”‚   β”œβ”€β”€ StockfishPlayer.js       # Engine move generation logic
β”‚   β”œβ”€β”€ StockfishStateView.js    # Performance and evaluation UI
β”‚   β”œβ”€β”€ main.js                  # App initialization
β”‚   └── extensions/              # Extra features (e.g., Markers, Arrows)
β”œβ”€β”€ server.js                    # Local dev server with security headers
β”œβ”€β”€ index.html                   # Main entry point
└── assets/                      # Styles, sounds, and opening books

Installation & Development

1. Install Dependencies

bun install

2. Start Development Server

bun run dev

Open http://localhost:3000. This runs the Bun bundler in watch mode and serves the app via server.js to ensure the required security headers are present.

3. Build for Production

bun run build

The optimized output will be in the dist directory.


Configuration

Core constants and default settings are located in src/Config.js.

Setting Default Description
DEFAULT_SKILL_LEVEL 20 Engine strength (1-20)
DEFAULT_DEPTH 16 Default thinking depth
WORKER_PATH /engine/...js Path to the Stockfish Web Worker
DEFAULT_THEME brown-wood Initial board theme

Security Requirements

Stockfish 18 utilizes multi-threaded WebAssembly, which depends on SharedArrayBuffer. For security reasons (Spectre/Meltdown mitigation), modern browsers only enable this feature if the page is cross-origin isolated.

The following headers MUST be present in your hosting environment:

  • Cross-Origin-Opener-Policy: same-origin
  • Cross-Origin-Embedder-Policy: require-corp

If these headers are missing, the engine will either fail to initialize or fall back to a slower, single-threaded mode.


Development & Contribution

We welcome contributions! Please feel free to open issues or submit pull requests.

Interested in more advanced chess tools? Check out our flagship app: πŸ‘‰ BoldChess Web App


Credits


License

This project is licensed under the GNU AGPLv3. See the LICENSE file for details.


Verified and maintained by BoldChess.com | A project by Labinator.com

About

Responsive chess web GUI to play against the Stockfish 18 chess engine. Multiple web GUI implementations have also been included.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Contributors

Languages