Developing Strapi plugins
The content of this page has not been updated to Strapi v5 yet.
This section is about developing Strapi plugins to use them as local plugins or to submit them to the Marketplace. Not what you're looking for? Read the plugins introduction and find your use case and recommended section to read from there.
Strapi allows the development of plugins that work exactly like the built-in plugins or 3rd-party plugins available from the Marketplace. Once created, your plugin can be:
- used as a local plugin, working only with a specific Strapi project,
- or submitted to the Marketplace to be shared with the community.
The first step to developing a Strapi plugin is to create it using the CLI-based generator. Then you'll be able to leverage the plugin APIs to add features to your plugin.
Plugin creation
Strapi provides a command line interface (CLI) for creating plugins. To create a plugin:
- Navigate to the root of a Strapi project.
- Run
yarn strapi generate
ornpm run strapi generate
in a terminal window to start the interactive CLI. - Choose "plugin" from the list, press Enter, and give the plugin a name in kebab-case (e.g.
my-plugin
) - Choose either
JavaScript
orTypeScript
for the plugin language. - Create a plugins configuration file if one does not already exist:
./config/plugins.js
or./config/plugins.ts
for TypeScript projects. - Enable the plugin by adding it to the plugins configurations file:
- JavaScript
- TypeScript
module.exports = {
// ...
'my-plugin': {
enabled: true,
resolve: './src/plugins/my-plugin' // path to plugin folder
},
// ...
}
export default {
// ...
'my-plugin': {
enabled: true,
resolve: './src/plugins/my-plugin' // path to plugin folder
},
// ...
}
- Run
npm install
oryarn
in the newly-created plugin directory. - (TypeScript-specific) Run
yarn build
ornpm run build
in the plugin directory. This step transpiles the TypeScript files and outputs the JavaScript files to adist
directory that is unique to the plugin. - Run
yarn build
ornpm run build
at the project root. - Run
yarn develop
ornpm run develop
at the project root.
Plugins created using the preceding directions are located in the plugins
directory of the application (see project structure).
During plugin development it is helpful to use the --watch-admin
flag to toggle hot reloading of the admin panel. See the Admin panel customization documentation for more details. (TypeScript specific) While developing your plugin, you can run yarn develop --watch-admin
or npm run develop -- --watch-admin
in the plugin directory to watch the changes to the TypeScript server files.
Plugin APIs
Strapi provides the following programmatic APIs for plugins to hook into some of Strapi's features:
📄️ Server API
Use the Server API to have your plugin interact with the backend server of Strapi.
📄️ Admin Panel API
Use the Admin Panel API to have your plugin interact with the admin panel of Strapi.
Plugins can also be used to add custom fields to Strapi.