RPG Dice RollerRPG Dice Roller
Home
Guide
API
  • Contributing
  • Code of Conduct
GitHub
Home
Guide
API
  • Contributing
  • Code of Conduct
GitHub
  • Guide

    • Introduction
    • Get Started
    • CLI
    • Usage
    • Customisation
  • Notation

    • What are notations?
    • Dice
    • Modifiers
    • Group Rolls
    • Describing Rolls
    • Maths

Get Started

Install

NPM
npm install @dice-roller/rpg-dice-roller
Yarn
yarn add @dice-roller/rpg-dice-roller
CDN
<!-- Replace {VERSION} with the version you want to use -->
<script src="https://cdn.jsdelivr.net/npm/@dice-roller/rpg-dice-roller@{VERSION}/lib/umd/bundle.min.js"></script>

Setup

ESM

You can import the dice roller and use it in your application, using ES standard modules like so:

import * as rpgDiceRoller from '@dice-roller/rpg-dice-roller';

If you only want to import specific components, you can do so like:

import { DiceRoller } from '@dice-roller/rpg-dice-roller';
CommonJS

Tips

If you're using Node.js with ES modules (import), instead of CommonJS (require), follow the ESM section instead.

You can also load the library using CommonJS, AMD, etc. with the UMD build:

const rpgDiceRoller = require('@dice-roller/rpg-dice-roller');

If you only want to import specific components, you can do so like:

const { DiceRoller } = require('@dice-roller/rpg-dice-roller');
Browser

Browser support

The dice roller may not work with older browsers. Please check the environment support.

Dependencies

First, you'll need to include some third party dependencies:

  • Math.js
  • Random.js
<script src="https://unpkg.com/mathjs@11.8.2/lib/browser/math.js"></script>
<script src="https://cdn.jsdelivr.net/npm/random-js@2.1.0/dist/random-js.umd.min.js"></script>

Dice Roller

You can either download the file locally, or use the CDN (Note umd in the path, instead of esm):

<!-- local file -->
<script src="./path/to/lib/umd/bundle.min.js"></script>

<!-- or CDN - Replace {VERSION} with the version you want to use -->
<script src="https://cdn.jsdelivr.net/npm/@dice-roller/rpg-dice-roller@{VERSION}/lib/umd/bundle.min.js"></script>

The UMD bundle provides the global variable, rpgDiceRoller, that is used to access the library.

<script>
  // create a new instance of the DiceRoller
  var diceRoller = new rpgDiceRoller.DiceRoller();
</script>
Edit this page
Last Updated: 07/02/2026, 21:45
Prev
Introduction
Next
CLI