Black King

chessboard2

The easiest way to embed a chess board on your site.

Download v1.0.0

As easy as two lines.

HTML

<div id="board1"></div>

JavaScript

const board1 = Chessboard2('board1', 'start')

Customize with a powerful API.

HTML

<div id="board2"></div>

JavaScript

const game = new Chess()
const board = Chessboard2('board2', 'start')

window.setTimeout(makeRandomMove, 500)

function makeRandomMove () {
  if (game.game_over()) return

  const legalMoves = game.moves()
  const randomIdx = Math.floor(Math.random() * legalMoves.length)
  game.move(legalMoves[randomIdx])
  board.position(game.fen())

  window.setTimeout(makeRandomMove, 500)
}