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-dice-pro

v1.1.0

Published

The best React dice component ๐ŸŽฒ

Downloads

282

Readme

React Dice Pro

The best React dice. Focus on optimization, customization and ease of use. Live example - react-dice-pro.ivanadmaers.com

Features

  • ๐Ÿš€ Optimization
  • ๐Ÿ”Œ React 16+ support
  • โœ… Ease of use
  • ๐Ÿ“ MIT license
  • ๐Ÿ“ฆ Lightweight
  • ๐Ÿ”ง Well-tested
  • ๐ŸŽ‰ NextJS, GatsbyJS and RemixJS support

Installation

# Via npm:
npm i react-dice-pro

# Via yarn:
yarn add react-dice-pro

Usage

import { useState } from 'react';

import { DicePro, IDiceFace } from 'react-dice-pro';

const App = () => {
  const [isPlaying, setIsPlaying] = useState(false);
  const [rollTrigger, setRollTrigger] = useState(0);
  const [targetFace, setTargetFace] = useState<null | IDiceFace>(null);

  const handlePlay = () => {
    if (isPlaying === true) {
      return;
    }

    const randomInt = getRandomInt(1, 6) as IDiceFace;

    setIsPlaying(true);

    setTargetFace(randomInt);
    setRollTrigger((prevState) => prevState + 1);
  };

  const handleRollComplete = () => {
    setIsPlaying(false);
  };

  return (
    <main>
      <h1>Roll the dice!</h1>
      <DicePro
        targetFace={targetFace}
        rollTrigger={rollTrigger}
        onRollComplete={handleRollComplete}
      />
      <button type="button" onClick={handlePlay} disabled={isPlaying}>
        Roll
      </button>
    </main>
  );
};

export default App;

Props

Where * means required

| Prop | Type | Default value | Description | |--|--|--|--| | targetFace* | null or number | - | The dice target face. Can be null or 1, 2, 3, 4, 5, 6 (The IDiceFace interface) | | rollTrigger* | number | - | The dice roll trigger. Every time the value changes the dice starts rolling | | onRollComplete | () => void | - | The callback function calls when the dice stops rolling | | soundSrc | string | - | Sound while the dice rolling. See more in the example folder | | className | string | - | The dice wrapper class name |

FAQ

๐Ÿง Where can I find an example of how to use the package?
๐Ÿ“ฃ You can find a live example on this site - react-dice-pro.ivanadmaers.com and in the example folder.

๐Ÿง How can I customize the dice?
๐Ÿ“ฃ The dice supports the className prop. You can pass it to customize the dice wrapper. The dice itself does not support customization yet.

๐Ÿง Is it possible to use this package with SSR frameworks (NextJS, GatsbyJS, etc)?
๐Ÿ“ฃ Yes, it is. The package does not use the global object window. So SSR frameworks can render it on server with no problems.

๐Ÿง What version of React does this package support?
๐Ÿ“ฃ Your versions should be:

  • react >=16.0.0
  • react-dom >=16.0.0
  • NodeJS >=14

๐Ÿง Are pull requests welcome?
๐Ÿ“ฃ Pull requests and improvement ideas are always welcome!

How to bootstrap the project locally

  1. Clone the repository

  2. Run

npm ci i

npm start

The last command runs webpack build to compile our package to a dist folder

  1. cd example/

  2. Run

npm ci i

npm start

The last command runs webpack dev server on localhost

License

MIT

Copyright (c) 2026-present, Ivan Admaers