Skip to main content
This walks through building a driver from the starter template, running it against Drawdy in development, and packaging it for distribution.

1. Get the starter

The fastest path is to clone the extension starter, a Vite project wired for the whole build:
The starter already depends on the protocol package for its types:
The protocol package is types only — it ships no runtime code. You import types from it and nothing lands in your bundle.

2. Write the module

A driver exports activate and onEvent. Here is a complete extension that adds a context-menu item, and each time it is clicked drops a sticky note on the canvas and flies the camera to it:
A few things to notice:
  • issueCommand is how you talk to Drawdy. Every call takes { type, driverId, requestId, req } and resolves to a response. driverId comes from your manifest; requestId is any value unique within your driver.
  • Subscriptions are set up by issuing a command. subscription:context-menu:clicked registers interest; the matching events then arrive in onEvent.
  • generateId mints ids for the canvas elements you create.
See the full command and event catalogue in the Protocol Reference.

3. The manifest

Every extension declares a manifest.json:
main is the entry bundle inside the .drawdyx zip. driverId is the stable identity Drawdy uses for install, storage, and command routing.

4. Run it in development

The starter runs a Vite dev server. On every save it rebuilds your extension and serves it at /built.drawdyx, exposing a /version endpoint that bumps on each build. Point Drawdy’s development mode at the dev server URL; Drawdy polls /version and hot-reloads the driver whenever it changes.

5. Package for distribution

This produces dist/<driver-id>.drawdyx — the zip of your manifest.json and main.js. That single file is the whole extension. Anyone can install it into Drawdy.

The .drawdyx format

A .drawdyx is a plain zip with two entries:
The bundle must be CommonJS with named exports — Drawdy instantiates it with new Function("exports", "module", code) and reads module.exports.activate. The starter’s Rollup config emits exactly this; if you roll your own build, target format: "cjs" with exports: "named".

Learn from the examples

The protocol repo ships three runnable drivers, drawdy-hello, drawdy-math-symbols, and drawdy-physics-engine, each built with this same template. See Examples for what each one shows, or browse examples/ on GitHub.