Skip to content
Jason Godesky edited this page Aug 15, 2026 · 20 revisions

Getting Started

To install the Revolutionary Games Common Foundry VTT Library in your project, run:

npm install @revolutionarygamesco/common-foundryvtt --save

You can then add methods from the library and call them like this:

import { generateID } from '@revolutionarygamesco/common-foundryvtt'

const id = generateID() // A random, 16-digit alphanumeric string

Types

This library provides Typescript types for Foundry VTT (verified as of v14), which makes it incompatible with other attempts to provide such types, like fvtt-types.

If you import any methods from this library, it will add all of the types to your global namespace (under foundry., e.g., foundry.documents.JournalEntry). If you just want the types but don’t have any use for any other methods, you can include them by adding this to any file in your project:

import '@revolutionarygamesco/common-foundryvtt'

Testing

This library ships mocks for Vitest that cover some of Foundry’s methods and objects (including game and foundry). Add it to your vitest.config.ts like so:

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    setupFiles: ['@revolutionarygamesco/common-foundryvtt/mocks/setup'],
    unstubGlobals: true
  }
})

Methods

Methods

Wrappers

Mocks

Clone this wiki locally