logologo
Get Started
Guide
Development
Plugins
API
English
简体中文
Get Started
Guide
Development
Plugins
API
English
简体中文
logologo

Quick Start

Plugin Development Overview
Write Your First Plugin
Project Structure

Server Development

Overview
Plugin
Collections
Database
DataSourceManager
ResourceManager
ACL
Middleware
Cache
Event
Context
Migration
Logger
I18n
Command
CronJobManager
Test

Client Development

Overview
Plugin
Context
Router
ACL
DataSourceManager
Resource
Request
Styles & Themes
Logger
I18n
Test

Others

Plugin Upgrade Guide
Languages
Dependency Management
Build
Previous PageOverview
Next PageContext

#Plugin

In NocoBase, Client Plugin is the main way to extend and customize frontend functionality. By extending the Plugin base class provided by @nocobase/client, developers can register logic, add page components, extend menus, or integrate third-party functionality at different lifecycle stages.

#Plugin Class Structure

A basic client-side plugin structure is as follows:

import { Plugin } from '@nocobase/client';

export class PluginHelloClient extends Plugin {
  async afterAdd() {
    // Executed after plugin is added
    console.log('Plugin added');
  }

  async beforeLoad() {
    // Executed before plugin loads
    console.log('Before plugin load');
  }

  async load() {
    // Executed when plugin loads, register routes, UI components, etc.
    console.log('Plugin loaded');
  }
}

export default PluginHelloClient;

#Lifecycle Description

Each plugin goes through the following lifecycle in sequence when the browser refreshes or the application initializes:

Lifecycle MethodExecution TimingDescription
afterAdd()Executed immediately after the plugin is added to the plugin managerThe plugin instance has been created at this point, but not all plugins have finished initializing. Suitable for lightweight initialization, such as reading configuration or binding basic events.
beforeLoad()Executed before all plugins' load()Can access all enabled plugin instances (this.app.pm.get()). Suitable for preparation logic that depends on other plugins.
load()Executed when the plugin loadsThis method is executed after all plugins' beforeLoad() completes. Suitable for registering frontend routes, UI components, and other core logic.

#Execution Order

Every time the browser refreshes, afterAdd() → beforeLoad() → load() will be executed

#Plugin Context and FlowEngine

Starting from NocoBase 2.0, client-side extension APIs are mainly concentrated in FlowEngine. In the plugin class, you can get the engine instance through this.engine.

// Access engine context in load() method
async load() {
  const { app, router, apiClient } = this.engine.context;
  console.log('Current app:', app);
}

For more content, see:

  • FlowEngine
  • Context