TUTORIAL
tutorial
6 min read

Create, Test & Package Your First Plugin

What you will build: A scaffolded plugin in JavaScript, Rust, or AssemblyScript, verified offline with the SDK test harness and mounted live with --dev-plugin.

Step 1: Scaffold a Plugin by Language

Scaffold a zero-build ES2024 plugin (manifest_schema: 3, entrypoint plugin.js) that needs no bundler or compilation:

Terminal + plugin.js js
opendash new plugin my-plugin --lang js --dir ./my-plugin

// plugin.js generated scaffold:
od.on("content/after_save", async (env) => {
  od.log.info("Saved entry: " + JSON.stringify(env.payload));
  return { ok: true };
});

Step 2: Offline Unit Testing with @opendash/sdk

Test Boa JS modules and cron handlers locally in Node.js before booting OpenDash using createTestHost from @opendash/sdk/test-harness:

plugin.test.mjs js
import { createTestHost } from "@opendash/sdk/test-harness";

const host = createTestHost({ kv: { count: 1 } });
host.loadModule((od) => {
  od.onCron("sync", async () => {
    const n = Number(od.kv.get("count") ?? 0);
    od.kv.set("count", n + 1);
    od.log.info("synced");
    return { count: n + 1 };
  });
});

const res = await host.runCron("sync");
// => { ok: true, value: { count: 2 } }

Step 3: Live Mount, Inspect Logs & Package

Dev, Logs & Pack CLI bash
# Mount plugin directory live on an isolated site root
OPENDASH_SITE_ROOT=./dev-site OPENDASH_PORT=18767 \
  opendash serve --dev --dev-plugin ./my-plugin

# Tail plugin runtime logs in another terminal
opendash logs my-plugin --owner plugin --follow

# Run offline ABI check and build an installable ZIP archive
opendash check plugin ./my-plugin
opendash pack plugin ./my-plugin --out ./my-plugin.zip
opendash schema plugin > plugin.schema.json

Step 4: Install & Enable Safely

Place ready folder plugins inside <site_root>/plugins/<slug>/ or upload my-plugin.zip in Plugins and click Enable. Configure plugin settings and secrets cleanly in Admin before triggering actions.

Next Steps

Edit Source URL:

Search OpenDash

Use Arrow keys & Enter to navigate Full search page →