npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-chess-board-editor

v0.2.0

Published

A highly flexible React Native library for creating and editing chess board positions (FEN strings) without enforcing game rules

Readme

react-native-chess-board-editor

npm version License: MIT

A highly flexible and customizable React Native library for creating and editing chess board positions (FEN strings) without enforcing game rules. Perfect for building puzzle creators, position analysis tools, or chess setup utilities.

📚 Full Documentation |


✨ Features

  • 🎯 Intuitive Drag & Drop - Smooth, native gesture handling powered by Reanimated 3
  • 🎨 Fully Customizable - Control colors, sizes, styles, and layouts
  • ♟️ Multiple Piece Sets - Includes alpha, cburnett, and merida piece sets, plus support for custom sets
  • 🔧 Granular Components - Use individual components or the unified BoardEditor
  • 🎭 No Chess Rules - Create any position, legal or illegal
  • 📋 FEN Support - Full FEN string editing and manipulation
  • ⚡ TypeScript - Complete type definitions included
  • 🧪 Well Tested - Comprehensive test coverage

📦 Installation

npm install react-native-chess-board-editor

or

yarn add react-native-chess-board-editor

Peer Dependencies

This library requires the following peer dependencies:

npm install react-native-gesture-handler react-native-reanimated react-native-svg

Make sure to complete the setup for react-native-gesture-handler and react-native-reanimated.


🚀 Quick Start

Basic Usage

import React, { useState } from 'react';
import { View } from 'react-native';
import { BoardEditor } from 'react-native-chess-board-editor';

export default function App() {
  const [fen, setFen] = useState('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1');

  return (
    <View style={{ flex: 1, padding: 20 }}>
      <BoardEditor
        initialFen={fen}
        onFenChange={setFen}
      />
    </View>
  );
}

Using Individual Components

import React, { useState } from 'react';
import { View } from 'react-native';
import {
  EditableBoard,
  PieceBank,
  FenDisplay,
  TurnToggler,
  CastlingRightsTogglers,
} from 'react-native-chess-board-editor';

export default function CustomEditor() {
  const [fen, setFen] = useState('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1');

  return (
    <View>
      <EditableBoard fen={fen} onFenChange={setFen} />
      <PieceBank />
      <FenDisplay fen={fen} onFenChange={setFen} editable />
      <TurnToggler turn="w" onTurnChange={(turn) => {/* handle */}} />
      <CastlingRightsTogglers castlingRights="KQkq" onCastlingChange={(rights) => {/* handle */}} />
    </View>
  );
}

🧩 Components

Core Components

| Component | Description | |-----------|-------------| | BoardEditor | All-in-one component combining board, bank, and controls | | EditableBoard | Interactive chess board with drag & drop | | PieceBank | Piece palette for adding pieces to the board | | FenDisplay | Display and edit FEN strings |

Control Components

| Component | Description | |-----------|-------------| | TurnToggler | Switch between white and black to move | | CastlingRightsTogglers | Toggle castling availability (K, Q, k, q) | | EnPassantInput | Set en passant target square | | EditorToolsPanel | Collection of editor utility buttons | | PieceSetSelector | Switch between different piece set styles | | FlipBoardButton | Rotate the board 180° |

Utility Components

| Component | Description | |-----------|-------------| | Piece | Render individual chess pieces | | RankLabels | Display rank labels (1-8) | | FileLabels | Display file labels (a-h) |


🎨 Customization

Theming

Use the BoardThemeProvider to customize board appearance:

import { BoardThemeProvider } from 'react-native-chess-board-editor';

<BoardThemeProvider
  theme={{
    lightSquareColor: '#F0D9B5',
    darkSquareColor: '#B58863',
    squareSize: 45,
  }}
>
  <BoardEditor initialFen={fen} onFenChange={setFen} />
</BoardThemeProvider>

Custom Piece Sets

Register and use custom piece renderers:

import { registerCustomPieceSet, BoardEditor } from 'react-native-chess-board-editor';

registerCustomPieceSet('myCustomSet', {
  K: (props) => <MyWhiteKing {...props} />,
  Q: (props) => <MyWhiteQueen {...props} />,
  // ... other pieces
});

<BoardEditor pieceSet="myCustomSet" />

Styling Props

All components accept standard React Native style props:

<EditableBoard
  squareSize={50}
  lightSquareColor="#ECECEC"
  darkSquareColor="#769656"
  style={{ borderRadius: 8 }}
/>

UI Configuration

The BoardEditor component accepts a nested uiConfig prop that allows you to configure all aspects of the editor UI:

<BoardEditor
  initialFen={fen}
  onFenChange={setFen}
  uiConfig={{
    // Board orientation
    flipped: false,

    // Piece bank configuration
    pieceBank: {
      show: true,
      layout: 'horizontal',
      pieceSize: 40,
      showLabel: true,
      labelConfig: {
        fontSize: 14,
        color: '#333',
        fontWeight: '600',
      },
      bankStyle: { backgroundColor: '#f5f5f5' },
      pieceStyle: { margin: 4 },
    },

    // Board configuration
    editableBoard: {
      coordinateLabels: {
        show: true,
        fontSize: 12,
        color: '#666',
      },
      boardStyle: { borderRadius: 4 },
      pieceStyle: { opacity: 1 },
    },

    // FEN display configuration
    fenDisplay: {
      show: true,
      editable: true,
      inputStyle: { fontSize: 14 },
      containerStyle: { padding: 8 },
    },

    // Editor tools panel configuration
    editorToolsPanel: {
      show: true,
      title: 'Editor Tools',
      initialExpanded: false,
      showTurnToggler: true,
      showCastlingRights: true,
      showEnPassantInput: true,
      showPieceSetSelector: true,
      containerStyle: { borderRadius: 8 },
    },

    // Flip board button configuration
    flipBoardButton: {
      show: true,
      location: 'overlay',
      variant: 'overlay',
      buttonStyle: { backgroundColor: '#007AFF' },
    },
  }}
/>

All nested configuration properties are optional and have sensible defaults. The nested structure provides full TypeScript IntelliSense support for easy discovery of available options.

Migrating from v0.1.0? See MIGRATION.md for a complete migration guide.


📖 API Documentation

For detailed API documentation, prop references, and advanced usage examples, visit:

📚 https://your-docs-site.com


🔧 Advanced Features

FEN Utilities

The library exports utility functions for FEN manipulation:

import { parseFen, updateFenField, validateFen } from 'react-native-chess-board-editor';

const fenParts = parseFen('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1');
const newFen = updateFenField(fen, 'turn', 'b');
const isValid = validateFen(fen);

Custom Piece Filtering

Filter pieces shown in the PieceBank:

import { PieceBank, whitePiecesOnly } from 'react-native-chess-board-editor';

<PieceBank pieceFilter={whitePiecesOnly} />

Board Flipping

The board can be flipped to show from black's perspective:

<EditableBoard fen={fen} onFenChange={setFen} flipped />

📋 Requirements

  • React Native >= 0.64
  • react-native-gesture-handler >= 2.0.0
  • react-native-reanimated >= 3.0.0
  • react-native-svg >= 13.0.0

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


🔗 Links


🙏 Acknowledgments


Made with ❤️ for the React Native community