Plugin Development Guide
A feature plugin adds a whole capability to Streamix: admin pages, public pages, API endpoints, settings and its own tables. It lives under src/product/addons/<id>/ with "feature": true in its manifest and is enabled by license entitlement + an admin toggle. Channel integrations (payment gateways, email providers…) are the other kind of add-on; see the Add-on Development Guide.
Bundled feature plugins: announcements, api, audit-logs, digest, maps, push (web push), sso, twofa (two-factor auth) and webhooks.
The plugin system comes from the shared CreativeCape core, so some names in the contract still reflect other products (for example the
learner/instructornav areas and course events). This page says which surfaces Streamix actually renders.
Anatomy
src/product/addons/announcements/
addon.json manifest (feature: true, premium, category…)
index.ts exports `plugin` (a FeaturePlugin)
schema.ts ensureSchema: idempotent CREATE TABLE
api.ts API handlers
admin.tsx admin page
installation-guide.md shown in the admin
{
"id": "announcements",
"name": "Announcements",
"type": "code",
"feature": true,
"products": ["*"],
"version": "1.0.0",
"premium": true,
"category": "announcements",
"vendor": "creative-cape.com"
}
A manifest may also declare templates (email/SMS/WhatsApp); they are seeded into the notification system when the plugin is activated.
The FeaturePlugin contract
Defined in src/core/plugins/types.ts:
| Field | Purpose | Rendered in Streamix? |
|---|---|---|
id, name, category? |
Identity and grouping on the Add-ons page | Yes |
ensureSchema? |
Idempotent table creation, run on activation | Yes |
nav? |
Sidebar entries; area: "admin" adds to the admin sidebar |
Admin area only |
adminPages? |
sub-slug → component at /admin/x/<id>/<slug> |
Yes |
publicPages? |
pattern → component at /x/<id>/<pattern> (e.g. verify/:code) |
Yes |
api? |
"METHOD pattern" → handler at /api/v1/ext/<id>/<path> |
Yes |
loginButtons? |
Sign-in buttons (e.g. SSO), listed by GET /api/v1/plugins/login-methods |
Not shown in the sign-in dialog yet |
settings? |
Per-plugin fields (text/secret/select/switch) edited on its admin page |
Yes |
hooks? |
Handlers for core events | Only admin.action is emitted today (from requirePermission) |
learnerPages?, slots? |
Member-area pages and injected components | Not rendered in Streamix yet |
Example
import type { FeaturePlugin } from "@/core/plugins/types";
import { ensureSchema } from "./schema";
import { adminList, save, remove } from "./api";
import AnnouncementsAdmin from "./admin";
export const plugin: FeaturePlugin = {
id: "announcements",
name: "Announcements",
category: "Engagement",
ensureSchema,
nav: [{ area: "admin", label: "Announcements", icon: "Megaphone", slug: "", permission: "settings" }],
adminPages: { "": AnnouncementsAdmin },
api: {
"GET admin/list": adminList,
"POST admin/save": save,
"DELETE admin/:id": remove,
},
};
API handlers
A handler receives (req, { params, query }). Use the same guards as core routes: requirePermission(action, resource) for admin endpoints, getCustomerId() (and getViewer() for profile-scoped data) for member endpoints.
export const adminList: PluginApiHandler = async () => {
const denied = await requirePermission("read", "settings");
if (denied) return denied;
const rows = await sql`SELECT * FROM announcement ORDER BY created_at DESC`;
return Response.json(rows);
};
Schema
export async function ensureSchema(): Promise<void> {
await sql`CREATE TABLE IF NOT EXISTS announcement (
id SERIAL PRIMARY KEY,
title VARCHAR(200) NOT NULL,
body TEXT DEFAULT '',
created_at TIMESTAMPTZ DEFAULT NOW()
)`;
}
Scope member data by customer_id, or by profile_id when it is per-viewer, like the rest of Streamix.
How plugins are served
Plugins don't add route files. Three catch-alls resolve active plugins at request time:
| Surface | Route file | URL |
|---|---|---|
| Admin pages | src/app/admin/(panel)/x/[...slug]/page.tsx |
/admin/x/<id>/<slug> |
| Public pages | src/app/(site)/x/[...slug]/page.tsx |
/x/<id>/<slug> |
| API | src/app/api/v1/ext/[addon]/[...path]/route.ts |
/api/v1/ext/<id>/<path…> |
The admin catch-all checks the nav item's permission. The API dispatcher matches "METHOD pattern" keys against the path (for example "DELETE admin/:id" matches DELETE /api/v1/ext/announcements/admin/42). Plugin endpoints are excluded from the public OpenAPI spec.
Activation and licensing
A plugin works when it is installed (in the generated ADDON_FEATURES, via npm run addons:bundle) and active (a row in plugin_state). setFeatureActive() in src/core/plugins/state.ts runs ensureSchema, seeds declared templates and stores the flag; deactivating hides nav, pages and API immediately and keeps the data. Plugin settings are saved in the same table.
Every feature plugin is premium by default (FREE_FEATURES is empty in src/core/channels/tiers.ts). featureBlock() in src/lib/premium.ts allows it when the license entitlements include the feature id (or */all) or a purchase code for it was activated. Admins toggle plugins and enter codes under Configuration → Add-ons.
When to write a plugin vs. core code
Use a plugin for optional features an operator may switch off (a support desk, announcements, SSO). Change core code (src/lib/ott, src/app/(site)) for behaviour every Streamix install needs, following the Developer Guide.
© CreativeCape Solutions · creative-cape.com · support@creative-cape.com