Skip to content

Get started ​

Install RPG Dice Roller and load it using the setup that matches your application.

If you're upgrading an existing application from v5, see Migrating from v5 to v6 first.

If you just want to try rolling dice before installing the library, use the dice playground.

Install ​

Install the library using your preferred package manager:

bash
npm install @dice-roller/rpg-dice-roller

To use the library directly in a browser without a build tool, see Browser setup.

Setup ​

Use ES modules in applications that support import, or CommonJS in applications that use require.

Import the components you need:

javascript
import { Roll, Roller } from '@dice-roller/rpg-dice-roller';

This works in Node.js projects configured for ES modules and browser applications using a build tool such as Vite.

You can also import the library as a namespace:

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

TypeScript type definitions are included with the package. No additional types package is required.

Browser setup ​

You can use RPG Dice Roller directly in a modern browser without an application build tool.

Use a <script type="module"> element to import the library.

An ESM-aware CDN such as esm.sh can resolve the library’s dependencies for you. Replace {VERSION} with the library version you want to use.

html
<script type="module">
  import { Roll, Roller } from 'https://esm.sh/@dice-roller/rpg-dice-roller@{VERSION}';

  // Use Roll and Roller here.
</script>

If you host the ESM build yourself, its runtime dependencies must also be resolvable by the browser, for example through an import map. The ESM bundle is not a standalone file.

Next steps ​

Continue to the usage guide to roll dice and work with the results.

MIT Licensed · Credits