Skip to content
AntFabric Corev1.0.0local

Your first plugin

This takes about fifteen minutes. The result: a plugin with a database table, a permission-checked route, a unit test, and a screen in every app.

Terminal window
pnpm plugin:new notes --mobile --team=notes-team
Option Default Meaning
name — Lowercase letters, digits and dashes. The id becomes af.<name>
--title Title Case of the name Display name
--team core-team Owning team (owner.team in the manifest)
--web / --admin on A user-app screen / an App Admin screen
--mobile off A phone screen

It writes plugins/notes/ and its contracts package — see plugin anatomy.

Terminal window
pnpm install # links @antfabric-plugin/notes and @antfabric-contracts/notes

Add it to the instance file, so it is built and migrated:

instances/local.yaml
plugins:
- af.example
- af.notes # ← new
Terminal window
pnpm --filter backend db:migrate # schema "notes", role af_notes, its permissions
pnpm dev # API, workers, user app, App Admin

Sign in at http://localhost:5173: Notes is in the navigation. App Admin shows it under its own entry. On the phone (pnpm mobile:go) it is on the home screen.

Terminal window
pnpm nx run @antfabric-plugin/notes:lint
pnpm nx run @antfabric-plugin/notes:typecheck
pnpm nx run @antfabric-plugin/notes:test
pnpm plugins:check
To Do
Add a table A new migration in db/migrations (never edit 0000_init.sql once applied), then db/schema.ts. See Server side
Add a route A controller method with @Permissions('notes:read'); register the controller in the module; pnpm api:spec
Add a screen A route in web/index.tsx (and mobile/index.tsx); a navigation route in plugin.yaml to link to it by id. See Screens
Update screens live Declare an event, publish it with PluginEvents. See Live updates and notifications
Tell someone Declare a notification type, send it with PluginNotifications
Run something later or on a schedule A workflow and a schedule. See Background work
Call another plugin Its contract. See Contracts between plugins
Add demo data demo.sql, run by pnpm demo:seed as your plugin’s role

Before the merge request, go through the review checklist.