Plugins
Accent CMS supports a WebAssembly plugin system built on the WebAssembly
Component Model and
WIT. Plugins are
sandboxed components that extend the CMS without compromising the host process.
Each plugin is a compiled .wasm component paired with a plugin.toml manifest
that declares which capabilities it provides.
Unlike a stringly-typed bytes-in/bytes-out protocol, the contract between host
and plugin is a set of typed WIT worlds: records, result<T, E> error
handling, and structural capabilities. The contract is the source of truth and
both sides generate their bindings from it – the host with
wasmtime::component::bindgen!, the guest with cargo-component (Rust) or
jco/componentize-js (JavaScript).
The Capability Surface
Plugins can provide several kinds of capabilities, each modelled as a WIT world:
| Capability | Description | Example |
|---|---|---|
| Content hooks | Transform content at lifecycle points | SEO injection, link rewriting |
| Filters | Custom template filters | {{ value | my_filter }} |
| Shortcodes | Inline content processors | [gallery]...[/gallery] |
| Routes | Custom HTTP endpoints | /api/search, /api/contact |
| Media hooks | Augment media discovery and processing | EXIF extraction, watermarking |
| Diagram renderers | Render fenced code blocks of a language | a custom [d2] renderer |
Because capabilities are structural, a plugin can reach only what its WIT world imports. The three host capabilities every plugin may use – configuration, logging, and runtime context – are always granted; outbound HTTP and filesystem access are deny-by-default and present only when a world imports them.
Enabling Plugins
Plugins are disabled by default. Enable them in config.yaml:
plugins: enabled: true directory: ./plugins # default location
When enabled is false (the default), no plugins are loaded and no WASM
runtime overhead is incurred. The plugin system is also resilient by design: a
missing directory, an invalid plugin.toml, or a runtime error never prevents
the server from starting or serving content.
Quick Start
Scaffold a complete, buildable plugin with the CLI and pick your language:
accent plugin new my-plugin --lang rust # or: --lang js
The generated project is a working content-hook plugin you can build and install in minutes. See Writing a Plugin for the full walkthrough.
To install someone else’s instead of writing your own, browse the
Hub – the signed registry
accent plugin install resolves against.
In This Chapter
- Structure and Metadata – the
plugin directory layout and the
plugin.tomlfile: required fields, hooks, filters, shortcodes, routes, and per-plugin configuration. - The Plugin Contract – the typed WIT worlds, the structural capability model, and the data types that cross the host/plugin boundary.
- Writing a Plugin – a complete
walkthrough for both toolchains: Rust with
cargo-componentand JavaScript withjco, from scaffold through build, install, and verify. - Media Hooks – the
on_media_discoverandon_media_processhooks for enriching media metadata and transforming processed images. - Managing Plugins – the
accent pluginCLI for scaffolding, listing, inspecting, installing, and removing plugins, plus hot reload and graceful error handling. - Security – the structural capability model, metering (fuel, epoch, and the per-plugin memory cap), scoped filesystem access, the outbound-HTTP allowlist, and API version compatibility.
- Configuration Reference – the
full
config.yamlreference for the plugin system and where to go next. - Publishing Artifacts –
accent package, which turns a plugin, theme, or starter template into the archive, checksum, and manifest a registry submission needs.
In this section
-
Plugin Structure and Metadata
How plugins are laid out on disk and how the plugin.toml file declares a plugin's name, version, and the hooks, filters, shortcodes, routes, and configuration it provides.
-
The Plugin Contract
Plugins implement typed WIT worlds. This page covers the worlds for every surface, the structural capability model, and the data types that cross the host/plugin boundary.
-
Writing a Plugin
A complete walkthrough for building an Accent CMS plugin in Rust (cargo-component) or JavaScript (jco) -- scaffold, code, build, install, and verify.
-
Media Hooks
The on_media_discover and on_media_process hooks let plugins enrich media metadata during content scanning and transform images after processing.
-
Managing Plugins
Use the accent plugin CLI to list, inspect, install, and remove plugins, and rely on hot reload and graceful error handling during development.
-
Plugin Security
How the plugin sandbox works -- structural capabilities, per-call metering (fuel, epoch, and a memory cap), API version checks, scoped filesystem access, and the outbound-HTTP allowlist.
-
Configuration Reference
The full config.yaml reference for the plugin system, with every option annotated, plus pointers to related guides.
-
Publishing Artifacts
Use accent package to turn a plugin, theme, or starter template into a publishable archive, a SHA-256, and a registry manifest.