Skip to content

Rust plugins

Extend the server without forking it: implement the Plugin trait (crates/server/src/plugin.rs) for one-time, synchronous setup() work (bind hooks, provision a collection your plugin depends on, spawn a background task) and extra HTTP routes under /api/plugins/<name> via routes(), then register it in a PluginRegistry — including from a downstream binary that depends on cratebase-server as a library, not just this repo’s own cratebase binary. This is a compile-time Rust trait, not a dynamically loaded or scripted plugin format. crates/server/src/cron_jobs.rs (the built-in SQL cron feature) is the closest in-repo reference for the “reactive system collection” shape a plugin author would follow, even though it isn’t built on the Plugin trait itself; crates/server/src/queue.rs (the built-in Queue plugin) is built on the trait, and is the reference for a plugin that needs its own fixed-interval background work: setup() receives a plain &App (not async), so a plugin wanting a periodic tick spawns its own tokio::spawn loop from inside setup() rather than relying on a scheduled_tasks() extension point — the trait doesn’t have one.