This template provides a minimal setup to develop a Re:Earth Visualizer Plugin with Vite, React, ShadCN, and Tailwind CSS.
- React 19.1.0 with TypeScript 5.7.2
- Vite 6.0.3 for build tooling
- TailwindCSS 4.1.10 for styling
- Radix UI components with ShadCN/UI
The structure of a Re:Earth Visualizer Plugin aligns with the definitions in reearth.yml. Specifically:
- A plugin can contain zero to multiple extensions.
- Extensions come in three types:
widgetstoryBlockandinfoboxBlock. However, in terms of structure, these three types are essentially the same when developing extensions. - Each extension must correspond to a unique JavaScript script.
- An extension can render its UI in three different locations:
main,modal, andpopup.mainrefers to the primary view of the extension, typically a widget panel or block panel.- You can prepare multiple UIs for
main,modal, andpopup. Each UI will be rendered in a sandboxed iframe, effectively acting as an independent Single Page Application (SPA).
This template includes a simple demo of a plugin with a widget extension. The demo helps illustrate the file structure.
First, define the plugin YAML file public/reearth.yml:
id: reearth-visualizer-plugin-shadcn-template
name: Visualizer plugin shadcn template
version: 1.0.0
extensions:
- id: demo
type: widget
name: Demo
schema:
groups:
- id: appearance
title: Appearance
fields:
- id: primary_color
title: Primary color
type: string
ui: colorAs shown, it contains a single extension demo of type widget.
Then, review the structure of the project:
my-project/
├── node_modules/
├── public/
│ └── reearth.yml // Plugin definition
├── src/
│ ├── extensions/
│ │ └── demo/ // Extension folder, naming by extension ID
│ │ ├── main/ // UI project for the main view
│ │ └── demo.ts // Extension script
│ └── shared/
│ ├── components/ // Shared components of ShadCN
│ ├── lib/ // Shared lib of ShanCN
│ ├── reearthTypes/ // Shared Re:Earth Visualizer Plugin API types
│ ├── global.css // Shared Global CSS of tailwind
│ └── utils.ts
├── dist/ // Output directory of the plugin build
├── dist-ui/ // Output directory for the UI build
├── package/ // Directory for packaging the plugin into a zip file
├── configs/ // Vite configuration files for both extensions and UI
├── scripts/
├── package.json
└── README.md
Use the built-in interactive script to easily manage extensions and UI components:
yarn manageThis interactive tool provides a menu-driven interface to:
- Create Extension - Generate new extensions with multiple UI components
- Create UI - Add new UI components to existing extensions
- Remove Extension - Delete extensions and all associated UIs
- Remove UI - Remove individual UI components
Features:
- Automated Setup: Creates all necessary files, folder structure, and templates
- Package.json Integration: Automatically adds/removes dev and build scripts
- YAML Management: Updates
public/reearth.ymlwith extension definitions - Validation: Ensures extension and UI names are valid JavaScript identifiers
- Safety Features: Confirmation prompts and override warnings for existing files
- Auto-build: Triggers initial builds for new extensions/UIs
Naming Rules:
- Extension IDs and UI names must start with a letter (a-z, A-Z)
- Can contain letters, digits, and underscores only
- No special characters, spaces, or reserved words
- Examples:
myExtension,my_extension,dashboard,settings
If you prefer manual setup:
- Update the
reearth.ymlfile in thepublicfolder. - Create a new folder in
src/extensionswith the extension ID as the folder name. - Create a new extension script file in the new folder with the extension ID as the file name.
- (Optional) Create a new UI project in the new extension folder if needed. You can refer to the
demo/mainfor the structure. - Update the scripts in
package.jsonto build the new extension.
yarn manageOpens the interactive extension management tool for creating and managing extensions and UIs.
Refer to the scripts in package.json. Here are explanations for some of them:
yarn dev:demo:mainStarts the development server for the main UI project of the demo extension.
Ensure you check the environment variables being passed in so you can add your own scripts for different UI projects of different extensions.
yarn build:demo:mainBuilds the main UI project of the demo extension to dist-ui/demo/main.
yarn build:demoBuilds the demo extension to dist. The reearth.yml file will also be copied to dist.
yarn buildBuilds the entire plugin (all extensions to dist), generating a zip file in the package folder.
Note that README.md and LICENSE will be included in the zip. Update this script to include build commands for additional extensions as needed.
yarn previewStarts the preview server on port 5005.
- Start a dev server for the UI project of the extension you are developing.
- Develop the UI, checking it with the dev server.
- Develop the extension script, with no immediate way to check the result.
- Build the plugin and generate the plugin zip file.
- Go to Re:Earth Visualizer, install the plugin via the zip file, and add the widget or block.
- Check the result.
This process is lengthy and results in low development efficiency.
We are working on adding a new feature to Re:Earth Visualizer to improve the development experience (DX) for plugins. Follow these steps:
-
Preparation:
- Run Re:Earth Visualizer locally. Only the front-end is required; you can use any backend, such as the OSS backend.
- Update the plugin code. You can test with the demo.
-
Run script:
yarn dev-buildit will:
- Start a dev server for the UI project as usual (usually you don't need to use this).
- Automatically build the UI upon edits.
- Automatically build the extension.
- Start a preview server at
http://localhost:5005.
- Set environment variables in the Re:Earth Visualizer front-end project:
REEARTH_WEB_DEV_PLUGIN_URLS='["http://localhost:5005"]'. The server will automatically restart after .env changes.
Done. Now Re:Earth Visualizer will offer two icon buttons in the editor header:
-
- This fetches plugin files from the plugin preview, automatically zips, and installs them.
- Click this only when initially setting up and after modifying
reearth.yml.
-
- This reloads all extensions from the plugin preview.
- Only the plugin reloads, which is much faster than reloading the entire page.
Once everything is set up, the improved DX workflow will be:
- Make any changes to the plugin code.
- Click
Reload Dev Plugin Extensionson the local Re:Earth Visualizer webpage.
This workflow significantly improves development efficiency compared to the traditional method.

