This guide walks you through creating, installing, and activating your first Sodium plugin.
- A running Sodium panel instance
- File system access to the
data/plugins/directory - The plugin system enabled in your Sodium configuration
Make sure your Sodium configuration includes:
{
"plugins": {
"enabled": true,
"active": []
}
}This is stored in the main config file managed by Sodium's database layer. If you are using the file-based database, this lives in data/config.json. For external databases (MySQL, PostgreSQL, SQLite), it is stored in the config table.
Create a new folder inside data/plugins/. The folder name should match your plugin ID:
mkdir -p data/plugins/my-first-pluginCreate data/plugins/my-first-plugin/plugin.json:
{
"id": "my-first-plugin",
"name": "My First Plugin",
"version": "1.0.0",
"type": "utility",
"author": "Your Name",
"description": "A simple plugin to learn the Sodium plugin system."
}This is the minimum required manifest. See the Manifest Reference for all available fields.
Create data/plugins/my-first-plugin/server.js:
export default function (sodium) {
sodium.logger.info('My first plugin is running!');
// Register a simple API endpoint
sodium.http.registerRoutes((router) => {
router.get('/hello', (req, res) => {
res.json({ message: 'Hello from my first plugin!' });
});
});
}This module:
- Logs a message when the plugin is activated
- Registers a GET endpoint at
/api/plugins/my-first-plugin/hello
You have two options:
Option A: Via the admin panel
Navigate to the plugin management page in the Sodium admin panel and click "Activate" on your plugin.
Option B: Via the admin API
curl -X POST http://localhost:3000/api/admin/plugins/my-first-plugin/activate \
-H "Authorization: Bearer <your-admin-token>"Option C: Via configuration
Add your plugin ID to the active array in the config:
{
"plugins": {
"enabled": true,
"active": ["my-first-plugin"]
}
}Then restart Sodium.
curl http://localhost:3000/api/plugins/my-first-plugin/helloExpected response:
{ "message": "Hello from my first plugin!" }You should see in the Sodium logs:
INFO [Plugin:my-first-plugin] My first plugin is running!
INFO [Plugins] Activated "my-first-plugin"
data/plugins/my-first-plugin/
plugin.json
server.js
- Manifest Reference — Learn about all manifest fields
- API Reference — Explore the full
sodiumAPI - Database — Add persistent storage to your plugin
- Hooks — Intercept and modify core events
- Examples — See complete example plugins