A modern, production-ready boilerplate for building Foundry VTT modules using React, TypeScript, Tailwind CSS, and Shadcn UI components.
- React 18 with TypeScript for type-safe component development
- Shadcn UI components for beautiful, accessible UI elements
- Tailwind CSS for utility-first styling
- Vite for fast development and optimized builds
- Foundry VTT v12+ compatibility (tested on v13)
- ApplicationV2 API for modern Foundry window management
- Hot Module Replacement support for development
- Example Implementation demonstrating business management features
- Node.js v18 or higher
- Foundry VTT v12 or higher (v13 recommended)
- Basic knowledge of React, TypeScript, and Foundry VTT module development
git clone <your-repo-url>
cd foundryvtt-react-shadcn-boilerplatenpm installBefore building, you'll want to customize the module for your needs:
-
Update
module.json:- Change the
id,title, anddescriptionfields - Update pack names if you're using compendiums
- Modify system compatibility if needed
- Change the
-
Update
package.json:- Change the
nameanddescriptionfields
- Change the
-
Update
src/main.tsx:- Replace
MODULE_IDconstant with your module ID - Rename
MainAppandBusinessManagerAppclasses to match your module - Customize the scene control buttons (names, icons, titles)
- Update template paths if you rename templates
- Important: Update CSS class names - do a find-and-replace for
foundry-capital-moduleto your module's class name in:src/styles/global.csstailwind.config.js(theimportantproperty)src/main.tsx(inclassesarrays)- Any component files using the class
- Replace
-
Update
vite.config.ts:- Change the output file name to match your module ID
-
Customize Components:
- Modify
src/App.tsxto build your main interface - Update or remove
src/components/BusinessManager.tsx(this is just an example) - Add your own components in
src/components/
- Modify
-
Update Templates:
- Modify
templates/app.hbsandtemplates/business-manager.hbsas needed - Ensure root element IDs match what you use in
main.tsx
- Modify
npm run buildThis creates a dist/ directory with:
- Your compiled JavaScript bundle
- Compiled CSS styles
module.json(copied from root)
You need to place this module in your Foundry VTT Data/modules folder.
Mac/Linux (Symlink - Recommended for Development):
ln -s "$(pwd)" ~/Library/Application\ Support/FoundryVTT/Data/modules/your-module-idWindows (Symlink):
mklink /D "C:\Users\YourName\AppData\Local\FoundryVTT\Data\modules\your-module-id" "C:\Path\To\This\Project"Alternative (Copy Method):
Simply copy the entire project folder to your Foundry Data/modules directory. Note: You'll need to rebuild and copy the dist/ folder after each change.
- Launch Foundry VTT
- Log in as a Gamemaster
- Go to Game Settings β Manage Modules
- Find your module and enable it
- Click Save Module Settings
Look for your module's button in the Scene Controls (left sidebar). The example includes buttons in the Token Controls section.
foundryvtt-react-shadcn-boilerplate/
βββ src/
β βββ components/ # React components
β β βββ ui/ # Shadcn UI components
β β βββ BusinessManager.tsx # Example component
β β βββ ...
β βββ systems/ # Foundry system logic
β β βββ CampaignManager.ts
β β βββ ...
β βββ styles/
β β βββ global.css # Global styles + Tailwind
β βββ types/
β β βββ foundry-shim.d.ts # TypeScript definitions
β βββ App.tsx # Main React app component
β βββ main.tsx # Foundry module entry point
βββ templates/ # Handlebars templates
β βββ app.hbs
β βββ business-manager.hbs
βββ packs/ # Optional: Compendium packs (see packs/README.md)
β βββ npcs/ # Actor compendium (if needed)
β βββ items/ # Item compendium (if needed)
β βββ scenes/ # Scene compendium (if needed)
βββ assets/ # Optional: Static assets (see assets/README.md)
β βββ icons/ # Custom icons (if needed)
β βββ images/ # Images (if needed)
β βββ sounds/ # Sound files (if needed)
βββ dist/ # Build output (generated)
βββ module.json # Foundry module manifest
βββ package.json
βββ vite.config.ts
βββ tailwind.config.js
βββ tsconfig.json
The packs/ directory is optional and currently empty. This boilerplate creates entities programmatically (see src/systems/CampaignManager.ts) rather than using compendium packs.
If you need compendium packs:
- See
packs/README.mdfor detailed instructions - Uncomment the
packssection inmodule.json - Add your pack content to the appropriate subdirectories
If you don't need packs:
- You can safely ignore or delete the
packs/directory - The
packssection inmodule.jsonis commented out by default
The assets/ directory is optional and currently empty. This boilerplate uses Foundry's built-in Font Awesome icons and doesn't require custom assets.
If you need custom assets:
- See
assets/README.mdfor detailed instructions - Add your images, icons, or sounds to the appropriate subdirectories
- Reference them in your code using the module path format
If you don't need assets:
- You can safely ignore or delete the
assets/directory
This boilerplate includes Shadcn UI setup. To add more components:
npx shadcn-ui@latest add [component-name]For example:
npx shadcn-ui@latest add dialog
npx shadcn-ui@latest add dropdown-menuComponents will be added to src/components/ui/.
This boilerplate includes a working example of a business management system to demonstrate:
- React state management with hooks
- Foundry API integration (game, ui, etc.)
- Application windows using Foundry's ApplicationV2
- Scene control buttons for easy access
- Shadcn UI components (Button, Card, etc.)
- Custom styling with Tailwind CSS
You can use this as a reference or remove it entirely and build your own features.
For development with hot-reloading, you can use:
npm run devNote: Hot-reloading requires additional proxy setup to work with Foundry VTT. For most development, you'll want to:
- Make changes to your code
- Run
npm run build - Refresh Foundry VTT (F5)
The project uses strict TypeScript. Type definitions for Foundry are provided in src/types/foundry-shim.d.ts. You may need to extend these based on your Foundry version.
- Tailwind CSS: Utility classes for rapid UI development
- Global CSS: Custom styles in
src/styles/global.css - Shadcn UI: Pre-built accessible components
npm run buildThe build output in dist/ is ready for distribution. Make sure to:
- Test thoroughly in Foundry VTT
- Update
module.jsonwith proper version numbers - Update repository URLs in
module.jsonif publishing - Consider minification and optimization (Vite handles this)
- Open Foundry DevTools: Press
F12orCmd + Option + I(Mac) - Console Tab: Look for logs prefixed with your module ID
- Network Tab: Verify
module.jsonand your JS bundle are loading - Source Maps: Enable in
vite.config.tsfor better debugging:build: { sourcemap: true, // ... }
Your module ID (defined in module.json and src/main.tsx) should be:
- Unique
- Lowercase
- Use hyphens instead of spaces
- Match your module folder name
The boilerplate uses Foundry's ApplicationV2 API with HandlebarsApplicationMixin:
- Modern window management
- React integration via root elements
- Proper cleanup on window close
React apps are mounted into Handlebars template root elements:
- Handlebars template provides the container
- React mounts into that container
- React handles all UI logic and state
This is a boilerplate template. Feel free to:
- Fork and customize for your needs
- Submit improvements via pull requests
- Report issues or suggest features
This boilerplate is provided as-is. Check the LICENSE file for details, or add your own license.
- Customize the module for your specific use case
- Add your features in
src/components/andsrc/systems/ - Style with Tailwind and Shadcn UI components
- Test thoroughly in Foundry VTT
- Build and distribute your module
- Keep your module ID consistent across all files
- Use TypeScript for better development experience
- Leverage Shadcn UI components for rapid UI development
- Test with different Foundry versions if targeting multiple
- Use Foundry's hooks system (
Hooks.on,Hooks.once) for integration - Check Foundry VTT documentation for API details
Happy Module Building! π²