Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

chess-captcha-react-jsx

YusungAN0MIT1.0.4TypeScript support: included

A React chessboard component for chess-based CAPTCHA systems. Features interactive drag-and-drop functionality, customizable board size, and real-time move validation. Built with TypeScript, React, and chess.js.

chess, captcha, chess-captcha, chess-puzzle, chess-game, chess-board

readme

chess-captcha-react-jsx

A React chessboard component for chess-based CAPTCHA systems. Features interactive drag-and-drop functionality, customizable board size, and real-time move validation. Built with TypeScript, React, and chess.js.

This component is designed to work with the chess-captcha-core library, which provides the CAPTCHA puzzle generation and verification logic.

Image

The source code for this GIF is available in the Github repository.

Installation

React Component

npm i chess-captcha-react-jsx

Quick Start

import { ChessBoard } from "chess-captcha-react-jsx";

function App() {
  const [FEN, setFEN] = useState(
    "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
  ); // Fetch generated FEN from your server

  const handleMove = (move: string) => {
    console.log("Player moved:", move);
    // Send user's move to your server to verify the answer
  };

  return (
    <ChessBoard
      onMove={handleMove}
      FEN={FEN}
      width={600} // Customizable board size
    />
  );
}

API Reference

ChessBoard Component

Props

interface ChessBoardProps {
  onMove: (move: string) => void; // Callback when a move is made
  FEN: string; // Chess position in FEN notation
  width?: number; // Board width in pixels (default: 480)
}

License

MIT