chessboard.js Documentation

repository·master·Indexed 24 days ago

https://github.com/oakmac/chessboardjs

A lightweight, standalone JavaScript chessboard widget for rendering chess positions. It serves as a flexible UI layer and does not include game logic or rule validation, though it is recommended for use with chess.js. Requires jQuery v3.4.1 or higher.

Tokens
298
Snippets
0
Records
3
Agent score
30%

What's inside chessboard.js

  1. What is chessboard.js?

    master

    chessboard.js is a standalone JavaScript chessboard component designed to be 'just a board'. It provides a powerful API for displaying chess positions without enforcing any specific game logic. It is highly flexible and can be used for:

    • Displaying game positions alongside commentary.
    • Building tactics websites where users guess moves.
    • Integrating with PGN databases for game playback.
    • Serving as the UI for a chess server.

    Note: It is highly recommended to use chessboard.js in conjunction with [chess.js] if you need to handle chess rules (e.g., move validation, turn tracking, check detection).

  2. Understand the scope and limitations of chessboard.js

    master

    The scope of chessboard.js is strictly limited to the visual representation of a board.

    It does not understand the rules of chess. It cannot determine:

    • How pieces move (e.g., knight jumps).
    • Whose turn it is.
    • If a king is in check.

    To implement game logic, you must use a separate library like chess.js to manage the state and rules, then use the chessboard.js API to update the board's visual state.