Introduction
Plugins are extensible modules in Matat's ecosystem. They allow you to add new features, hook into workflows, or integrate with third-party services seamlessly. This guide walks you through creating a basic plugin from start to finish.
Prerequisites
Ensure you have:
- ✓ Node.js (v16+)
- ✓ A Matat API key (from your dashboard)
Initialize Your Plugin
Create a new directory and install the plugin boilerplate:
mkdir my-matat-plugin
cd my-matat-plugin
npm init -y
npm install @matat/plugins
Write Your Plugin
Create a file named index.js
:
const { Plugin } = require('@matat/plugins');
module.exports = class MyPlugin extends Plugin {
constructor(options) {
super(options);
this.name = 'my-plugin';
}
async onInit() {
// Register a simple event hook
this.hooks.on('app.start', async () => {
console.log('Plugin initialized!');
});
}
}
This base plugin listens to Matat's start event and prints a message.
Deploy
Build and deploy your plugin:
npm run build
matat plugin deploy --apikey YOUR_API_KEY
Once deployed, your plugin will appear in your Matat plugin dashboard and activate on your next deployment.