Build your first plugin
This walkthrough creates a minimal plugin and runs it locally.
Prerequisites
- Dot X app running (starts the local plugin server on port 3001)
- Node 16+ or Deno 1.41+
Scaffold with the CLI (recommended)
The easiest way to create a new plugin is with the interactive scaffolder:
bash
npx @dotmatrixlabs/create-dotx-pluginThe TUI walks you through choosing a name, ID, and runtime (Deno or Node). A project folder is created automatically based on the plugin ID.
CLI flags (for CI / automation)
bash
npx @dotmatrixlabs/create-dotx-plugin --name "My Plugin" --node--name <name>: Plugin display name--id <id>: Override the generated plugin ID (kebab-case)--deno(default): Deno + TypeScript template--node: Node + TypeScript + esbuild template with<plugin-name>.dotxpluginpackaging--force: Overwrite existing files
Manual setup (Node)
If you prefer to set up manually:
- Create a folder and initialise it:
bash
mkdir my-plugin && cd my-plugin
npm init -y
npm install @dotmatrixlabs/dotx-plugin-sdk
npm install -D esbuild- Create
manifest.json:
json
{
"id": "my-plugin",
"name": "My Plugin",
"version": "0.1.0",
"description": "My first Dot X plugin",
"author": "Your Name",
"dotxVersion": ">=2.0.0",
"permissions": [],
"main": "main.js"
}- Create
main.ts:
ts
import Plugin, { runPlugin } from "@dotmatrixlabs/dotx-plugin-sdk";
class MyPlugin extends Plugin {
async onLoad() {
await this.ui.showToast({ message: "Hello from plugin!", type: "success" });
}
}
if (require.main === module) {
runPlugin(MyPlugin);
}- Add a build script to
package.json:
json
{
"scripts": {
"build": "esbuild main.ts --bundle --outfile=main.js --format=cjs --platform=node --target=node16 --minify",
"start": "node main.js"
}
}- Build and run:
bash
npm run build
npm startManual setup (Deno)
Create
manifest.json(same as above, set"main": "main.ts").Create
main.ts:
ts
import Plugin, { runPlugin } from "npm:@dotmatrixlabs/dotx-plugin-sdk";
class MyPlugin extends Plugin {
async onLoad() {
await this.ui.showToast({ message: "Hello from plugin!", type: "success" });
}
}
runPlugin(MyPlugin);- Add
deno.json:
json
{
"tasks": { "start": "deno run --allow-all main.ts" },
"nodeModulesDir": "auto"
}- Run:
bash
deno task startWhat happens
When the plugin starts, it connects to the Dot X plugin server, registers itself using manifest.json, and calls your onLoad() method. You should see a toast notification in the app.
Next steps
- Add a settings page — see the SettingsBuilder Components reference
- Persist data with
this.config— see Plugin Config - React to device changes — see Events & Communication
- Check out more Examples