Plugin creation
There are many ways to create a Strapi 5 plugin, but the fastest and recommended way is to use the Plugin SDK.
The Plugin SDK is a set of commands orientated around developing plugins to use them as local plugins or to publish them on NPM and/or submit them to the Marketplace.
With the Plugin SDK, you do not need to set up a Strapi project before creating a plugin.
The present guide covers creating a plugin from scratch, linking it to an existing Strapi project, and publishing the plugin. If you already have an existing plugin, you can instead retrofit the plugin setup to utilise the Plugin SDK commands (please refer to the Plugin SDK reference for a full list of available commands).
This guide assumes you want to develop a plugin external to your Strapi project. However, the steps largely remain the same if you want to develop a plugin within your existing project. If you are not using a monorepo the steps are exactly the same.
yalc must be installed globally (with npm install -g yalc
or yarn global add yalc
).
Getting started with the Plugin SDKβ
The Plugin SDK helps you creating a plugin, linking it to an existing Strapi project, and building it for publishing.
The full list of commands and their parameters are available in the Plugin SDK reference. The present page will guide on using the main ones.
Creating the pluginβ
To create your plugin, ensure you are in the parent directory of where you want it to be created and run the following command:
- Yarn
- NPM
yarn dlx @strapi/sdk-plugin init my-strapi-plugin
npx @strapi/sdk-plugin init my-strapi-plugin
The path my-strapi-plugin
can be replaced with whatever you want to call your plugin, including the path to where it should be created (e.g., code/strapi-plugins/my-new-strapi-plugin
).
You will be ran through a series of prompts to help you setup your plugin. If you selected yes to all options the final structure will be similar to the default plugin structure.