Skip to main content
This page builds Counter, a small plugin with a panel, a command, a setting and an action you can undo. The finished plugin is in the editor repository, under examples/counter-plugin.

1. Create it

The name is the plugin’s name in the registry: @scope/name, in lowercase. The command writes a counter folder (--path chooses another one); it does not need a NanoForge project around it.

2. Run it in the editor

In another terminal, start the editor with the plugin as a dev plugin:
The Counter panel is in the bottom right dock. In the simple layout, which shows only the main panels, open it with View › Panels › Counter (or View › Layouts › All panels); the same entry shows it again once closed. A plugin can put its panel in the simple layout with "essential": true, for the few panels most work needs. When you save a source file, the editor reloads the plugin without reloading the page.
@nanoforge-dev/editor-sdk and @nanoforge-dev/editor-vite-plugin are not published on npm yet, so pnpm install fails on them. Until they are, point both at a checkout of the editor repository in the plugin’s package.json ("link:/path/to/editor/packages/sdk" and "link:/path/to/editor/tooling/vite-plugin"): examples/README.md in that repository has the steps.

3. The manifest

nanoforge.manifest.json declares what the plugin adds. The editor reads it before running any code.
  • activation: the plugin’s code loads when its panel is first shown or its command first runs.
  • widgets: a panel named Counter, docked bottom right by default.
  • commands and menus: a command, listed in the Edit menu and in the command palette (Ctrl+Shift+P).
  • settings: a number shown in Settings › Counter. Its full key is @acme/counter.step.

4. The code

src/index.ts exports the plugin. activate gets a context: the editor’s services, and subscriptions, where you put everything the plugin adds so it is removed with the plugin.
src/Panel.svelte is a Svelte 5 component. It receives the widget instance, and uses the editor’s own Button.
count is an ObservableValue from the SDK: Svelte reads it as a store ($count).

5. Try it

  • Click Add twice, then press Ctrl+Z with the panel focused: the counter goes back by one. The step is in the History panel too.
  • Run Edit › Add to the counter, or find it in the command palette.
  • Change Settings › Counter › Step to 5 and add again.

6. Install it without the dev mode

Copy dist/ to ~/.nanoforge/editor/plugins/@acme/counter (every project) or to <project>/.nanoforge/plugins/@acme/counter (one project, and it can be committed with it). Reload the editor.

Where to go next