Plugin
In NocoBase, Server Plugin is the primary way to extend server-side functionality. You can extend the Plugin base class provided by @nocobase/server in your plugin directory's src/server/plugin.ts, then register events, APIs, permissions, and other custom logic at different lifecycle stages.
Plugin Class
A basic plugin class structure is as follows:
Lifecycle
Plugin lifecycle methods execute in the following order. Each method has its specific execution timing and purpose:
Execution Order Description
Typical execution flow of lifecycle methods:
- Static Initialization Phase:
staticImport() - Application Startup Phase:
afterAdd()→beforeLoad()→load() - First Plugin Enable Phase:
afterAdd()→beforeLoad()→load()→install() - Second Plugin Enable Phase:
afterAdd()→beforeLoad()→load() - Plugin Disable Phase:
afterDisable()is executed when plugin is disabled - Plugin Remove Phase:
remove()is executed when plugin is removed
app and Related Members
In plugin development, you can access various APIs provided by the application instance through this.app -- this is the core entry point for extending plugin functionality. The app object contains various functional modules of the system, which you can use in plugin lifecycle methods.
app Member List
For detailed usage of each module, please refer to the corresponding documentation chapters.
Related Links
- Server Development Overview -- Overview and navigation for all server-side modules
- Collections -- Define or extend data table structures with code
- Database -- CRUD, Repository, transactions, and database events
- Migration -- Data migration scripts for plugin upgrades
- Event -- Application-level and database-level event listening and handling
- ResourceManager -- Register custom REST APIs and actions
- Writing Your First Plugin -- Create a complete plugin from scratch
- Logger -- Record system logs
- ACL -- Define permissions and access policies
- Cache -- Manage system-level cache
- CronJobManager -- Register and manage scheduled tasks
- I18n -- Multi-language translation
- Command -- Register custom CLI commands
- DataSourceManager -- Manage multiple data sources

