react-minesweeper

react-minesweeper is a classic minesweeper game written as a React component. You can set the amount of fields and a bomb chance. Styles are only applied by CSS classes so it's easy to customize.

Usage no npm install needed!

<script type="module">
  import reactMinesweeper from 'https://cdn.skypack.dev/react-minesweeper';
</script>

README

react-minesweeper

react-minesweeper is a classic minesweeper game written as a React component. You can set the amount of fields and a bomb chance. Styles are only applied by CSS classes so it's easy to customize.

Link to the demo


Installation:

npm install --save react-minesweeper

Usage:

Import the default styling as shown in the demo page or create your own styles

import "react-minesweeper/lib/minesweeper.css";

Render the component

 <Minesweeper
    onWin={() => console.log("GAME WON")}
    onLose={() => console.log("GAME LOST")}
    bombChance={0.15} // 15% chance that a field will contain a bomb
    width={10} // amount of fields horizontally
    height={10} // amount of fields vertically
/>

Is there something wrong?

Please tell me!