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.
1. Generate it
Section titled “1. Generate it”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.
2. Link it and select it
Section titled “2. Link it and select it”pnpm install # links @antfabric-plugin/notes and @antfabric-contracts/notesAdd it to the instance file, so it is built and migrated:
plugins: - af.example - af.notes # ← new3. Migrate and run
Section titled “3. Migrate and run”pnpm --filter backend db:migrate # schema "notes", role af_notes, its permissionspnpm dev # API, workers, user app, App AdminSign 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.
4. Check it
Section titled “4. Check it”pnpm nx run @antfabric-plugin/notes:lintpnpm nx run @antfabric-plugin/notes:typecheckpnpm nx run @antfabric-plugin/notes:testpnpm plugins:check5. Make it yours
Section titled “5. Make it yours”| 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.