Skip to content

Anatomy of a plugin ​

Typical layout for a Node plugin:

my-plugin/
  manifest.json     # Plugin metadata (required)
  main.ts           # Plugin source (TypeScript)
  main.js           # Compiled entry point (built by esbuild)
  package.json      # npm project file
  README.md

For Deno plugins, main.js is replaced by running main.ts directly — no build step needed.

Key files ​

  • manifest.json: All required fields including id, name, version, description, author, dotxVersion, permissions, and main.
  • main.ts: Extends Plugin, calls runPlugin(YourClass).

Minimal entry (Node) ​

ts
import Plugin, { runPlugin } from "@dotmatrixlabs/dotx-plugin-sdk";

class MyPlugin extends Plugin {
  async onLoad() {
    this.config.init({ defaults: { enabled: true } });
  }
}

if (require.main === module) {
  runPlugin(MyPlugin);
}

Minimal entry (Deno) ​

ts
import Plugin, { runPlugin } from "npm:@dotmatrixlabs/dotx-plugin-sdk";

class MyPlugin extends Plugin {
  async onLoad() {
    this.config.init({ defaults: { enabled: true } });
  }
}

runPlugin(MyPlugin);

Lifecycle hooks ​

HookWhen called
onLoad()After successful registration with the host
onUnload()On graceful shutdown (SIGINT / SIGTERM)