docs/docs/en/ai-dev/watermark-plugin.md
This tutorial demonstrates how to use a single sentence to have AI develop a complete NocoBase watermark plugin -- from creating the scaffold to enabling and verifying, all done by AI.
After enabling the plugin:
:::tip Recommended Reading
:::
Make sure you have:
:::warning Note
client (v1) to client-v2, and client-v2 is still under development. The client code generated by AI development is based on client-v2 and can only be used under the /v/ path. It is available for early access and experimentation, but is not recommended for production use.:::
In your NocoBase project root directory, send the following prompt to AI:
Help me use nocobase-plugin-development skill to develop a NocoBase watermark plugin.
Requirements: overlay a semi-transparent watermark on the page showing the currently logged-in username to prevent data leaks via screenshots.
Periodically check if the watermark DOM has been removed and regenerate it if so.
Support configuring watermark text, opacity, and font size in the plugin settings page.
The plugin name is @my-project/plugin-watermark
After receiving the requirements, AI will automatically execute the following steps:
AI will first analyze which NocoBase extension points this plugin needs, then present a development plan. For example:
Server-side:
- A
watermarkSettingscollection to store watermark configuration (text, opacity, font size)- A custom API to read and write watermark settings
- ACL configuration: logged-in users can read, admins can write
Client-side:
- A plugin settings page with a form to configure watermark parameters
- Watermark rendering logic that reads the configuration and overlays the watermark on the page
- Tamper detection with a timer to monitor the watermark DOM
After you confirm the plan, AI starts writing code.
<!-- Screenshot of AI outputting the development plan in the terminal needed -->yarn pm create @my-project/plugin-watermark
AI generates a standard plugin directory structure under packages/plugins/@my-project/plugin-watermark/.
AI will generate the following files:
watermarkSettings table with text, opacity, and fontSize fieldsMutationObserver + timer; the watermark is immediately regenerated if the DOM is removedAI automatically generates Chinese and English language packs -- no extra action needed from you:
src/locale/zh-CN.json -- Chinese translationssrc/locale/en-US.json -- English translationsyarn pm enable @my-project/plugin-watermark
After enabling, open the NocoBase page and you'll see the watermark overlaying the content.
<!-- Video needed: from entering the prompt -> AI generating code -> enabling the plugin -> watermark appearing on the page -> opening the settings page to adjust parameters -> watermark updating accordingly -->From entering the prompt to having a working plugin, it takes approximately 3-5 minutes. AI completed the following work:
| Task | Manual Dev Estimate | AI Completion |
|---|---|---|
| Create scaffold | 2 minutes | Automatic |
| Collection + API | 20 minutes | Automatic |
| Plugin settings page | 30 minutes | Automatic |
| Watermark rendering + tamper detection | 40 minutes | Automatic |
| ACL configuration | 10 minutes | Automatic |
| Internationalization | 15 minutes | Automatic |
| Total | ~2 hours | ~5 minutes |
The watermark plugin primarily involves frontend rendering and simple backend storage. If you want to learn what else AI can help you with -- such as custom blocks, complex collection relationships, workflow extensions, and more -- check out Supported Capabilities.