chess-captcha-react-jsx
Version:
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.
63 lines (42 loc) • 1.49 kB
Markdown
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](https://www.npmjs.com/package/chess-captcha-core) library, which provides the CAPTCHA puzzle generation and verification logic.

The source code for this GIF is available in the Github repository.
```bash
npm i chess-captcha-react-jsx
```
```tsx
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
/>
);
}
```
```typescript
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)
}
```
MIT
A React chessboard component